Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get and update sync code only after sync chain is created #6182

Merged
merged 1 commit into from
Jul 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions browser/resources/settings/brave_sync_page/brave_sync_configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ Polymer({
},

attached: async function() {
const [syncCode, deviceList] = await Promise.all([
this.browserProxy_.getSyncCode(),
this.browserProxy_.getDeviceList()
])
this.syncCode = syncCode
const deviceList = await this.browserProxy_.getDeviceList()
this.addWebUIListener('device-info-changed', this.handleDeviceInfo_.bind(this))
this.handleDeviceInfo_(deviceList)
},
Expand All @@ -82,11 +78,24 @@ Polymer({
return displayDate.toDateString()
},

onViewSyncCode_: function() {
/*
* This only sets sync code when it is not already set. It needs to be cleared
* when sync chain reset
*/
ensureSetSyncCode_: async function() {
if (!!this.syncCode)
bsclifton marked this conversation as resolved.
Show resolved Hide resolved
return
const syncCode = await this.browserProxy_.getSyncCode()
this.syncCode = syncCode
},

onViewSyncCode_: async function() {
await this.ensureSetSyncCode_()
this.syncCodeDialogType_ = 'words'
},

onAddDevice_: function() {
onAddDevice_: async function() {
await this.ensureSetSyncCode_()
this.syncCodeDialogType_ = 'choose'
},

Expand All @@ -101,6 +110,9 @@ Polymer({
return
}
await this.browserProxy_.resetSyncChain();
// Clear sync code because user might use the same page to create a new sync
// chain without reload
this.syncCode = undefined
const router = Router.getInstance();
router.navigateTo(router.getRoutes().BRAVE_SYNC);
}
Expand Down