Skip to content

Commit

Permalink
fix(popup): add fallback if localstorage is disabled; #338
Browse files Browse the repository at this point in the history
  • Loading branch information
sereneblue committed May 2, 2020
1 parent d41a388 commit a5254ee
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions src/popup/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -899,22 +899,40 @@ export default class App extends Vue {
await this['$store'].dispatch('initialize');
let version = localStorage.getItem('version');
let needsUpdate: boolean = false;
if (localStorage != null) {
let needsUpdate: boolean = false;
let version = localStorage.getItem('version');
if (version === null || version != this.settings.version) {
localStorage.setItem('version', this.settings.version);
needsUpdate = true;
}
if (version === null || version != this.settings.version) {
localStorage.setItem('version', this.settings.version);
needsUpdate = true;
}
let localizations = localStorage.getItem('localizations');
if (localizations === null || needsUpdate) {
this.localizations = await browser.runtime.sendMessage({
action: 'localize',
});
localStorage.setItem('localizations', JSON.stringify(this.localizations));
} else {
this.localizations = JSON.parse(localizations);
}
let localizations = localStorage.getItem('localizations');
if (localizations === null || needsUpdate) {
let isDesktop = localStorage.getItem('isDesktop');
if (isDesktop === null) {
let platform = await browser.runtime.getPlatformInfo();
this.isDesktop = platform.os != 'android';
localStorage.setItem('isDesktop', JSON.stringify(this.isDesktop));
} else {
this.isDesktop = JSON.parse(isDesktop);
}
} else {
this.localizations = await browser.runtime.sendMessage({
action: 'localize',
});
localStorage.setItem('localizations', JSON.stringify(this.localizations));
} else {
this.localizations = JSON.parse(localizations);
let platform = await browser.runtime.getPlatformInfo();
this.isDesktop = platform.os != 'android';
}
this.getCurrentPage();
Expand All @@ -938,15 +956,6 @@ export default class App extends Vue {
this.tmp.rangeFrom = this.settings.headers.spoofIP.rangeFrom;
this.tmp.rangeTo = this.settings.headers.spoofIP.rangeTo;
let isDesktop = localStorage.getItem('isDesktop');
if (isDesktop === null) {
let platform = await browser.runtime.getPlatformInfo();
this.isDesktop = platform.os != 'android';
localStorage.setItem('isDesktop', JSON.stringify(this.isDesktop));
} else {
this.isDesktop = JSON.parse(isDesktop);
}
if (this.isDesktop) {
let detectedFP = await browser.runtime.sendMessage({
action: 'getTabFP',
Expand Down

0 comments on commit a5254ee

Please sign in to comment.