Skip to content

Commit 3b77ac0

Browse files
authored
Merge pull request #13 from Monadical-SAS/nikita-sidepanel-realtime-updates
feat: real-time updates
2 parents e9cbbde + db81b7f commit 3b77ac0

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

src/argo-archive-list.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ export class ArgoArchiveList extends LitElement {
125125
if (msg.type === "pages") this.pages = msg.pages || [];
126126
});
127127
port.postMessage({ type: "getPages" });
128+
129+
// @ts-expect-error - TS7006 - Parameter 'msg' implicitly has an 'any' type.
130+
chrome.runtime.onMessage.addListener((msg) => {
131+
if (msg.type === "pageAdded") {
132+
// ask the background for a fresh list
133+
port.postMessage({ type: "getPages" });
134+
}
135+
});
128136
}
129137

130138
render() {

src/ext/browser-recorder.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ class BrowserRecorder extends Recorder {
125125
}
126126

127127
if (numOtherRecorders > 0) {
128-
console.log(
129-
`closing session, not detaching, ${numOtherRecorders} other recording tab(s) left`,
130-
);
128+
console.log(`closing session, not detaching, ${numOtherRecorders} other recording tab(s) left`);
131129
return this.sessionClose([]);
132130
} else {
133131
console.log("detaching debugger, already tabs stopped");
@@ -236,9 +234,7 @@ class BrowserRecorder extends Recorder {
236234
this.doUpdateStatus();
237235
} catch (msg) {
238236
// @ts-expect-error - TS2339 - Property 'failureMsg' does not exist on type 'BrowserRecorder'.
239-
this.failureMsg = chrome.runtime.lastError
240-
? chrome.runtime.lastError.message
241-
: msg;
237+
this.failureMsg = chrome.runtime.lastError ? chrome.runtime.lastError.message : msg;
242238
this.doUpdateStatus();
243239
throw msg;
244240
}
@@ -343,7 +339,10 @@ class BrowserRecorder extends Recorder {
343339
// @ts-expect-error - TS2339 - Property 'db' does not exist on type 'BrowserRecorder'.
344340
if (this.db) {
345341
// @ts-expect-error - TS2339 - Property 'db' does not exist on type 'BrowserRecorder'.
346-
return this.db.addPage(pageInfo);
342+
const result = this.db.addPage(pageInfo);
343+
344+
chrome.runtime.sendMessage({ type: "pageAdded" });
345+
return result;
347346
}
348347
}
349348

@@ -372,9 +371,7 @@ class BrowserRecorder extends Recorder {
372371
prr.resolve(res);
373372
} else {
374373
// @ts-expect-error - TS7005 - Variable 'prr' implicitly has an 'any' type.
375-
prr.reject(
376-
chrome.runtime.lastError ? chrome.runtime.lastError.message : "",
377-
);
374+
prr.reject(chrome.runtime.lastError ? chrome.runtime.lastError.message : "");
378375
}
379376
};
380377

0 commit comments

Comments
 (0)