Skip to content

Commit

Permalink
Store the device ID generated by the simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Dec 25, 2023
1 parent dd2aff2 commit 6d27565
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion webextensions/common/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export const onNewDevice = new EventListenerManager();
export const onUpdatedDevice = new EventListenerManager();
export const onObsoleteDevice = new EventListenerManager();

const SEND_TABS_SIMULATOR_ID = '[email protected]';

let mMyDeviceInfo = null;

async function getMyDeviceInfo() {
Expand Down Expand Up @@ -154,7 +156,16 @@ async function updateSelf() {

updateSelf.updating = true;

await ensureDeviceInfoInitialized();
const [devices] = await Promise.all([
browser.runtime.sendMessage(SEND_TABS_SIMULATOR_ID, { type: 'get-devices' }),
ensureDeviceInfoInitialized(),
]);
if (devices) {
const myDeviceFromSimulator = devices.find(device => device.myself);
if (mMyDeviceInfo.simulatorId != myDeviceFromSimulator.id)
mMyDeviceInfo.simulatorId = myDeviceFromSimulator.id;
}

configs.syncDeviceInfo = mMyDeviceInfo = {
...clone(configs.syncDeviceInfo),
timestamp: Date.now(),
Expand Down

0 comments on commit 6d27565

Please sign in to comment.