Skip to content

Commit 15a1b73

Browse files
committed
Handle stale YouTube dashboard bridge
1 parent 1911b53 commit 15a1b73

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

chrome-extension/dashboard.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@
44
const requestEvent = 'infovore-youtube-import-request';
55
const statusEvent = 'infovore-youtube-import-status';
66

7+
function dispatchStatus(status) {
8+
control.dataset.extensionStatus = JSON.stringify(status);
9+
window.dispatchEvent(new Event(statusEvent));
10+
}
11+
712
async function emitStatus(extra = {}) {
813
const stored = await chrome.storage.local.get([
914
'historyImportStatus',
1015
'lifelogSyncStatus',
1116
]);
1217
const history = stored.historyImportStatus ?? {};
1318
const status = stored.lifelogSyncStatus ?? {};
14-
control.dataset.extensionStatus = JSON.stringify({
19+
dispatchStatus({
1520
extensionReady: true,
1621
state: status.state ?? 'idle',
1722
stage: status.stage ?? 'idle',
@@ -23,10 +28,17 @@
2328
lastError: String(status.lastError ?? ''),
2429
...extra,
2530
});
26-
window.dispatchEvent(new Event(statusEvent));
2731
}
2832

2933
window.addEventListener(requestEvent, () => {
34+
if (!chrome.runtime?.sendMessage) {
35+
dispatchStatus({
36+
extensionReady: false,
37+
state: 'error',
38+
lastError: 'Extension was updated. Reload this page and try again.',
39+
});
40+
return;
41+
}
3042
const action = control.dataset.importAction;
3143
const type = action === 'cancel'
3244
? 'lifelog-sync-cancel'

chrome-extension/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "infovore YouTube Capture",
4-
"version": "1.11.0",
4+
"version": "1.11.1",
55
"description": "Privately syncs cross-device YouTube history, saved progress, and measured Chrome viewing to infovore.",
66
"minimum_chrome_version": "120",
77
"permissions": [

tests/extension.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test('Chrome extension manifest is least-privilege and captures YouTube SPA page
1212
'utf8',
1313
));
1414
assert.equal(manifest.manifest_version, 3);
15-
assert.equal(manifest.version, '1.11.0');
15+
assert.equal(manifest.version, '1.11.1');
1616
assert.deepEqual(manifest.permissions.sort(), ['alarms', 'storage']);
1717
assert.deepEqual(manifest.host_permissions, [
1818
'https://infovore.skyhong.tw/*',
@@ -41,6 +41,7 @@ test('dashboard bridge exposes import status without exposing capture credential
4141
assert.match(source, /lifelog-sync-cancel/);
4242
assert.match(source, /lifelogSyncStatus/);
4343
assert.doesNotMatch(source, /captureSettings|captureToken|authorization|Bearer/);
44+
assert.match(source, /Extension was updated\. Reload this page and try again\./);
4445
});
4546

4647
test('daily lifelog sync has startup catch-up, overlap, and an hourly due check', () => {

0 commit comments

Comments
 (0)