Skip to content

Commit 1f5f376

Browse files
committed
fix concurrency between acquiring local and session storage
1 parent 0c859e1 commit 1f5f376

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/api-monitor-cs-isolated.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,21 @@ import {
88
import { getSettings, onSettingsChange } from './api/settings.ts';
99
import { getSession, onSessionChange } from './api/session.ts';
1010

11-
getSettings().then((settings) => {
11+
Promise.all([getSettings(), getSession()]).then(([settings, session]) => {
1212
windowPost({ msg: EMsg.SETTINGS, settings });
13+
windowPost({ msg: EMsg.SESSION, session });
14+
15+
portListen(windowPost);
16+
windowListen(runtimePost);
1317

1418
onSettingsChange((newValue) => {
1519
windowPost({ msg: EMsg.SETTINGS, settings: newValue });
1620
});
17-
});
18-
19-
getSession().then((session) => {
20-
windowPost({ msg: EMsg.SESSION, session });
21-
2221
onSessionChange((newValue) => {
2322
windowPost({ msg: EMsg.SESSION, session: newValue });
2423
});
25-
});
2624

27-
portListen(windowPost);
28-
windowListen(runtimePost);
25+
runtimePost({ msg: EMsg.CONTENT_SCRIPT_LOADED });
2926

30-
runtimePost({ msg: EMsg.CONTENT_SCRIPT_LOADED });
31-
32-
__development__ && console.log('api-monitor-cs-isolated.ts');
27+
__development__ && console.log('api-monitor-cs-isolated.ts', performance.now());
28+
});

src/api-monitor-cs-main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ windowListen((o) => {
7878
}
7979
});
8080

81-
__development__ && console.debug('api-monitor-cs-main.ts');
81+
__development__ && console.debug('api-monitor-cs-main.ts', performance.now());

0 commit comments

Comments
 (0)