Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
erosman authored Dec 5, 2023
1 parent d5867d5 commit e65e756
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/content/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,21 @@ export class Sync {
await browser.storage.local.set(pref);
}

static hasOldData(obj) {
// FP v3 OR FP v7
return Object.hasOwn(obj, 'settings') || Object.hasOwn(obj, 'foxyProxyEdition');
}

static async getSync(pref) {
if (!pref.sync) { return; }
if (pref.managed) { return; }

const syncPref = await browser.storage.sync.get();

// check sync from old version 3-7
if (!Object.keys(pref)[0] &&
(Object.hasOwn(syncPref, 'settings') || Object.hasOwn(syncPref, 'foxyProxyEdition'))) {
Object.keys(syncPref).forEach(i => pref[i] = syncPref[i]); // set sync data to pref to migrate next in background.js
return;
if ((!Object.keys(pref)[0] || this.hasOldData(pref)) && this.hasOldData(syncPref)) { // (local has no data OR has old data) AND sync has old data
Object.keys(syncPref).forEach(i => pref[i] = syncPref[i]); // set sync data to pref to migrate next in background.js
return;
}

// convert object to array & filter proxies
Expand Down

0 comments on commit e65e756

Please sign in to comment.