From cb55a17227343a0b86b49d0cd47e3ed9a3fb0cd4 Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Fri, 28 Mar 2025 10:57:39 +0100 Subject: [PATCH] ui: force getting url for location in tabmanagers --- frontend/app/player/common/ListWalker.ts | 15 +++++++-------- frontend/app/player/web/MessageManager.ts | 6 ++++-- frontend/app/player/web/TabManager.ts | 15 +++++++++------ frontend/app/player/web/WebPlayer.ts | 2 ++ 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/frontend/app/player/common/ListWalker.ts b/frontend/app/player/common/ListWalker.ts index e37083120..a5c80a643 100644 --- a/frontend/app/player/common/ListWalker.ts +++ b/frontend/app/player/common/ListWalker.ts @@ -124,13 +124,9 @@ export default class ListWalker { * Assumed that the current message is already handled so * if pointer doesn't change is returned. */ - moveGetLast(t: number, index?: number): T | null { - let key: string = 'time'; // TODO - let val = t; - if (index) { - key = '_index'; - val = index; - } + moveGetLast(t: number, index?: number, force?: boolean, debug?: boolean): T | null { + const key: string = index ? '_index' : 'time'; + const val = index ? index : t; let changed = false; // @ts-ignore @@ -143,7 +139,10 @@ export default class ListWalker { this.movePrev(); changed = true; } - return changed ? this.list[this.p - 1] : null; + if (debug) { + console.log(this.list[this.p - 1]) + } + return changed || force ? this.list[this.p - 1] : null; } prevTs = 0; diff --git a/frontend/app/player/web/MessageManager.ts b/frontend/app/player/web/MessageManager.ts index 1a532ffcc..d6052fd5e 100644 --- a/frontend/app/player/web/MessageManager.ts +++ b/frontend/app/player/web/MessageManager.ts @@ -288,15 +288,17 @@ export default class MessageManager { } if (tabId) { + const stateUpdate: { currentTab?: string, tabs?: Set } = {} if (this.activeTab !== tabId) { - this.state.update({ currentTab: tabId }); + stateUpdate['currentTab'] = tabId; this.activeTab = tabId; this.tabs[this.activeTab].clean(); } const activeTabs = this.state.get().tabs; if (activeTabs.size !== this.activeTabManager.tabInstances.size) { - this.state.update({ tabs: this.activeTabManager.tabInstances }); + stateUpdate['tabs'] = this.activeTabManager.tabInstances; } + this.state.update(stateUpdate) } if (this.tabs[this.activeTab]) { diff --git a/frontend/app/player/web/TabManager.ts b/frontend/app/player/web/TabManager.ts index 597bc1894..7ab04291f 100644 --- a/frontend/app/player/web/TabManager.ts +++ b/frontend/app/player/web/TabManager.ts @@ -98,6 +98,7 @@ export default class TabSessionManager { private readonly state: Store<{ tabStates: { [tabId: string]: TabState }; tabNames: { [tabId: string]: string }; + location?: string; }>, private readonly screen: Screen, private readonly id: string, @@ -415,14 +416,16 @@ export default class TabSessionManager { } } /* === */ - const lastLocationMsg = this.locationManager.moveGetLast(t, index); + const lastLocationMsg = this.locationManager.moveGetLast(t, index, true); if (lastLocationMsg) { - const { tabNames } = this.state.get(); - if (lastLocationMsg.documentTitle) { - tabNames[this.id] = lastLocationMsg.documentTitle; + const { tabNames, location } = this.state.get(); + if (location !== lastLocationMsg.url) { + if (lastLocationMsg.documentTitle) { + tabNames[this.id] = lastLocationMsg.documentTitle; + } + // @ts-ignore comes from parent state + this.state.update({ location: lastLocationMsg.url, tabNames }); } - // @ts-ignore comes from parent state - this.state.update({ location: lastLocationMsg.url, tabNames }); } const lastPerformanceTrackMessage = diff --git a/frontend/app/player/web/WebPlayer.ts b/frontend/app/player/web/WebPlayer.ts index 2977f95e4..ee92c7891 100644 --- a/frontend/app/player/web/WebPlayer.ts +++ b/frontend/app/player/web/WebPlayer.ts @@ -100,6 +100,8 @@ export default class WebPlayer extends Player { // @ts-ignore window.playerJumpToTime = this.jump.bind(this); + // @ts-ignore + window.__OPENREPLAY_DEV_TOOLS__.player = this; } preloadFirstFile(data: Uint8Array, fileKey?: string) {