Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Defer the migration until local registration info has been fetched (#…
Browse files Browse the repository at this point in the history
…2934)

Fixes #2919, migration issues
Fixes #2902, haywire notification on startup
  • Loading branch information
ianb authored and jaredhirsch committed May 31, 2017
1 parent d34e034 commit 1aa0b9e
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions addon/webextension/background/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ this.auth = (function() {
let sentryPublicDSN = null;
let abTests = {};

catcher.watchPromise(browser.storage.local.get(["registrationInfo", "abTests"]).then((result) => {
let registrationInfoFetched = catcher.watchPromise(browser.storage.local.get(["registrationInfo", "abTests"]).then((result) => {
if (result.abTests) {
abTests = result.abTests;
}
Expand Down Expand Up @@ -177,22 +177,24 @@ this.auth = (function() {
};

exports.setDeviceInfoFromOldAddon = function(newDeviceInfo) {
if (!(newDeviceInfo.deviceId && newDeviceInfo.secret)) {
throw new Error("Bad deviceInfo");
}
if (registrationInfo.deviceId === newDeviceInfo.deviceId &&
registrationInfo.secret === newDeviceInfo.secret) {
// Probably we already imported the information
return Promise.resolve(false);
}
registrationInfo = {
deviceId: newDeviceInfo.deviceId,
secret: newDeviceInfo.secret,
registered: true
};
initialized = false;
return browser.storage.local.set({registrationInfo}).then(() => {
return true;
return registrationInfoFetched.then(() => {
if (!(newDeviceInfo.deviceId && newDeviceInfo.secret)) {
throw new Error("Bad deviceInfo");
}
if (registrationInfo.deviceId === newDeviceInfo.deviceId &&
registrationInfo.secret === newDeviceInfo.secret) {
// Probably we already imported the information
return Promise.resolve(false);
}
registrationInfo = {
deviceId: newDeviceInfo.deviceId,
secret: newDeviceInfo.secret,
registered: true
};
initialized = false;
return browser.storage.local.set({registrationInfo}).then(() => {
return true;
});
});
};

Expand Down

0 comments on commit 1aa0b9e

Please # to comment.