Skip to content

Commit 6f087eb

Browse files
committed
Merge branch 'main' into nikita-torrent-sharing
2 parents e7d3485 + cac7ef3 commit 6f087eb

12 files changed

Lines changed: 464 additions & 9 deletions

src/argo-archive-list.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import "@material/web/list/list-item.js";
77
import "@material/web/checkbox/checkbox.js";
88
import "@material/web/icon/icon.js";
99
import "@material/web/labs/card/elevated-card.js";
10-
// @ts-expect-error
1110
import filingDrawer from "assets/images/filing-drawer.avif";
1211

1312
import { getLocalOption } from "./localstorage";

src/argo-shared-archive-list.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import "@material/web/icon/icon.js";
88
import "@material/web/labs/card/elevated-card.js";
99
import "@material/web/button/filled-button.js";
1010
import "@material/web/button/outlined-button.js";
11-
// @ts-expect-error
1211
import filingDrawer from "assets/images/filing-drawer.avif";
1312

1413
import { getLocalOption, setSharedArchives } from "./localstorage";
Lines changed: 1 addition & 0 deletions
Loading

src/assets/images/downloading.avif

89.4 KB
Binary file not shown.

src/assets/images/forest.avif

353 KB
Binary file not shown.
120 KB
Binary file not shown.

src/assets/images/sharing.avif

50.9 KB
Binary file not shown.

src/ext/bg.ts

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ function sidepanelHandler(port) {
9595
// @ts-expect-error - TS2339 - Property 'port' does not exist on type 'BrowserRecorder'.
9696
self.recorders[tabId].port = port;
9797
self.recorders[tabId].doUpdateStatus();
98+
} else if (isRecordingEnabled) {
99+
// Send the current recording state even if no recorder exists for this tab
100+
port.postMessage({
101+
type: "status",
102+
recording: false, // No recorder for this tab
103+
autorun,
104+
// @ts-expect-error
105+
collId: defaultCollId,
106+
});
98107
}
99108
port.postMessage(await listAllMsg(collLoader));
100109
break;
@@ -353,8 +362,18 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo) => {
353362

354363
if (changeInfo.url && !isValidUrl(changeInfo.url, skipDomains)) {
355364
stopRecorder(tabId);
365+
366+
// Ensure debugger is detached when navigating to a skipped domain
367+
try {
368+
chrome.debugger.detach({ tabId }, () => {
369+
// Debugger detached, ignore any errors as it might already be detached
370+
});
371+
} catch (e) {
372+
// Ignore errors - debugger might already be detached
373+
}
374+
356375
delete self.recorders[tabId];
357-
// let the side-panel know the canRecord/UI state changed
376+
// let the side-panel know the 'canRecord'/UI state changed
358377
// @ts-expect-error
359378
if (sidepanelPort) {
360379
sidepanelPort.postMessage({ type: "update" });
@@ -440,6 +459,9 @@ async function startRecorder(tabId, opts) {
440459
let err = null;
441460
// @ts-expect-error - TS7034 - Variable 'sidepanelPort' implicitly has type 'any' in some locations where its type cannot be determined.
442461
if (sidepanelPort) {
462+
// Set the port on the recorder so it can send status updates
463+
// @ts-expect-error
464+
self.recorders[tabId].port = sidepanelPort;
443465
sidepanelPort.postMessage({ type: "update" });
444466
}
445467
const { waitForTabUpdate } = opts;
@@ -449,9 +471,28 @@ async function startRecorder(tabId, opts) {
449471
try {
450472
self.recorders[tabId].setCollId(opts.collId);
451473
await self.recorders[tabId].attach();
474+
475+
// Send status update after successful attach
476+
// @ts-expect-error
477+
if (sidepanelPort && self.recorders[tabId]) {
478+
self.recorders[tabId].doUpdateStatus();
479+
}
452480
} catch (e) {
453481
console.warn(e);
454482
err = e;
483+
484+
// Clean up on error
485+
// @ts-expect-error
486+
if (err?.message?.includes("already attached")) {
487+
// Try to detach and delete the recorder
488+
try {
489+
chrome.debugger.detach({ tabId }, () => {
490+
delete self.recorders[tabId];
491+
});
492+
} catch (detachErr) {
493+
console.warn("Failed to detach debugger:", detachErr);
494+
}
495+
}
455496
}
456497
return err;
457498
}
@@ -462,6 +503,19 @@ async function startRecorder(tabId, opts) {
462503
function stopRecorder(tabId) {
463504
if (self.recorders[tabId]) {
464505
self.recorders[tabId].detach();
506+
507+
// Ensure the sidepanel is notified about the stop
508+
// @ts-expect-error - TS7034 - Variable 'sidepanelPort' implicitly has type 'any' in some locations where its type cannot be determined.
509+
if (sidepanelPort) {
510+
sidepanelPort.postMessage({
511+
type: "status",
512+
recording: false,
513+
autorun,
514+
// @ts-expect-error - defaultCollId implicitly has an 'any' type.
515+
collId: defaultCollId,
516+
});
517+
}
518+
465519
return true;
466520
}
467521

src/globals.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
declare module "*.svg";
2+
declare module "*.png";
3+
declare module "*.avif"
4+
declare module "*.jpg";
25
declare module "*.html";
36
declare module "*.scss";
47
declare module "*.sass";

0 commit comments

Comments
 (0)