Skip to content

Commit bb4d316

Browse files
committed
[chrome] add a few markdirtys
1 parent 68518b8 commit bb4d316

File tree

5 files changed

+13
-25
lines changed

5 files changed

+13
-25
lines changed

packages/chrome/src/History.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { browser } from "./Browser";
33
import { StatefulClass } from "./StatefulClass";
44
import type { Tab } from "./Tab";
55
import { sendFrame } from "./proxy/ipc";
6+
import { markDirty } from "./storage";
67

78
// history api emulation
89
export class HistoryState extends StatefulClass {
@@ -105,6 +106,7 @@ export class History {
105106
this.tab.canGoBack = this.canGoBack();
106107
this.tab.canGoForward = this.canGoForward();
107108

109+
markDirty();
108110
return this.states[this.index];
109111
}
110112
replace(
@@ -130,6 +132,7 @@ export class History {
130132
this.tab.canGoBack = this.canGoBack();
131133
this.tab.canGoForward = this.canGoForward();
132134

135+
markDirty();
133136
return this.states[this.index];
134137
}
135138
go(delta: number, navigate: boolean = true): HistoryState {
@@ -164,6 +167,7 @@ export class History {
164167
this.tab.canGoBack = this.canGoBack();
165168
this.tab.canGoForward = this.canGoForward();
166169

170+
markDirty();
167171
return newstate;
168172
}
169173
canGoBack(): boolean {

packages/chrome/src/components/TabStrip/TabStrip.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { setContextMenu } from "../Menu";
1515
import { browser, forceScreenshot, pushTab } from "../../Browser";
1616
import { defaultFaviconUrl } from "../../assets/favicon";
1717
import { DragTab } from "./DragTab";
18+
import { markDirty } from "../../storage";
1819

1920
type VisualTab = {
2021
tab: Tab;
@@ -186,6 +187,7 @@ export function TabStrip(
186187

187188
if (s.activetab != tab.tab) {
188189
s.activetab = tab.tab;
190+
markDirty();
189191
}
190192
};
191193

packages/chrome/src/storage.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ setInterval(() => {
3030
saveBrowserState();
3131
dirty = false;
3232
}
33-
}, 5000);
33+
}, 3000);
34+
35+
// just in case
36+
setInterval(() => {
37+
saveBrowserState();
38+
dirty = false;
39+
}, 10000);
3440

3541
window.addEventListener("beforeunload", (e) => {
3642
if (dirty) {

packages/sandbox/controller.html

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,13 @@
11
<title>Proxy Sandbox Controller</title>
22
<script>
33
function wake(controller) {
4-
console.log("wakling");
54
window.parent.postMessage({ $sandboxsw$type: "ready" }, "*");
65
}
76
navigator.serviceWorker
87
.register("/sw.js", {
98
scope: "./",
109
})
1110
.then((registration) => {
12-
console.log("Service Worker registered with scope:", registration.scope);
13-
console.log("Registration installing:", registration.installing);
14-
console.log("Registration waiting:", registration.waiting);
15-
console.log("Registration active:", registration.active);
16-
17-
// Monitor the registration for changes
18-
registration.addEventListener("updatefound", () => {
19-
console.log("SW update found!");
20-
const newWorker = registration.installing;
21-
console.log("New worker state:", newWorker?.state);
22-
23-
newWorker?.addEventListener("statechange", () => {
24-
console.log("SW state changed to:", newWorker.state);
25-
});
26-
});
27-
28-
// Check current controller
29-
console.log("Current controller:", navigator.serviceWorker.controller);
30-
3111
if (navigator.serviceWorker.controller) {
3212
// there's probably already a service worker
3313
wake(navigator.serviceWorker.controller);

packages/sandbox/sw.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,3 @@ self.addEventListener("activate", (e) => {
1515
});
1616

1717
console.log("sw initialized");
18-
19-
addEventListener("message", (e) => {
20-
console.log(e);
21-
});

0 commit comments

Comments
 (0)