Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #33685 from ferjm/bug1235343.sync.manager.getters.…
Browse files Browse the repository at this point in the history
…setters.races

Bug 1235343 - [TV][Sync] SyncManager getters and setters can be racy. r=yifan
  • Loading branch information
begeeben committed Dec 29, 2015
2 parents 6777e7e + 1319ac6 commit a05d9ae
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tv_apps/smart-system/js/sync_manager.js
Expand Up @@ -186,9 +186,9 @@
set state(state) {
state = state || SyncStateMachine.state;
this.debug('Setting state', state);
this.store.set(SYNC_STATE, state);
this.updateStateDeferred = new Promise(resolve => {
asyncStorage.setItem(SYNC_STATE, state, () => {
this.store.set(SYNC_STATE, state);
if (state === 'disabled' || state === 'enabled' ||
state === 'enabling') {
this.updateStatePreference().then(() => {
Expand All @@ -208,9 +208,8 @@
},

set error(error) {
asyncStorage.setItem(SYNC_STATE_ERROR, error, () => {
this.store.set(SYNC_STATE_ERROR, error);
});
this.store.set(SYNC_STATE_ERROR, error);
asyncStorage.setItem(SYNC_STATE_ERROR, error);
},

get error() {
Expand All @@ -219,9 +218,8 @@

set lastSync(now) {
var lastSync = now;
asyncStorage.setItem(SYNC_LAST_TIME, lastSync, () => {
this.store.set(SYNC_LAST_TIME, lastSync);
});
this.store.set(SYNC_LAST_TIME, lastSync);
asyncStorage.setItem(SYNC_LAST_TIME, lastSync);
},

get lastSync() {
Expand Down

0 comments on commit a05d9ae

Please sign in to comment.