Skip to content

Commit b35150e

Browse files
committed
[frontend] fix issues with tab logic
1 parent 7050101 commit b35150e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

frontend/src/Tab.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export class Tab extends StatefulClass {
8989
};
9090
}
9191
deserialize(de: SerializedTab) {
92+
if (id >= de.id) id = de.id + 1;
9293
this.id = de.id;
9394
this.title = de.title;
9495
this.history.deserialize(de.history);

frontend/src/browser.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,14 @@ export class Browser extends StatefulClass {
9393
build(): HTMLElement {
9494
let shell = <Shell tabs={use(this.tabs)} activetab={use(this.activetab)} />;
9595

96-
if (!this.activetab) {
96+
let de = localStorage["browserstate"];
97+
if (de) {
98+
browser.deserialize(JSON.parse(de));
99+
} else {
97100
let tab = this.newTab();
98101
this.activetab = tab;
99102
}
103+
100104
if (this.built) throw new Error("already built");
101105
this.built = true;
102106

@@ -141,10 +145,6 @@ export class Browser extends StatefulClass {
141145
export function createBrowser(): Browser {
142146
let browser = new Browser(createState({}));
143147
Object.setPrototypeOf(browser, Browser.prototype);
144-
let de = localStorage["browserstate"];
145-
if (de) {
146-
browser.deserialize(JSON.parse(de));
147-
}
148148

149149
return browser;
150150
}

0 commit comments

Comments
 (0)