fix(server-storage): keep duplicated tabs off live journals, drain writes around remove-all, normalize legacy Stalker rows on the move

- A page marks its unconfirmed-writes record closed on pagehide (not into
  the back-forward cache); a new page takes over the previous page load's
  saved writes only when that record is closed, stale or missing, so a
  duplicated tab, which copies sessionStorage, leaves the running tab its
  writes.
- PlaylistsService.removeAll lets queued playlist writes land first and
  makes writes issued meanwhile wait until it finished; the server store
  refuses a document without an id.
- Moving browser data sets the explicit Stalker portal-mode flag on rows
  from before it (withExplicitStalkerPortalFlag, now shared with
  PlaylistsService).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
4grayandClaude Opus 5.5 committed 2026-10-12 23:59:18 +02:00
1 parent f956758cce
commit 37c14d7d89
13 files changed
+278 -50

No files matched your search

@@ -26,6 +26,29 @@ export function isFullStalkerPortalUrl(url: string): boolean {
return url.includes('/stalker_portal') || url.includes('/server/load.php');
}
/**
* A Stalker playlist saved before the explicit flag existed, with the flag
* set from its URL; any other playlist comes back unchanged.
*/
export function withExplicitStalkerPortalFlag<
T extends {
macAddress?: string;
isFullStalkerPortal?: boolean;
portalUrl?: string;
url?: string;
},
>(playlist: T): T {
if (!playlist?.macAddress || playlist.isFullStalkerPortal !== undefined) {
return playlist;
}
return {
...playlist,
isFullStalkerPortal: isFullStalkerPortalUrl(
playlist.portalUrl ?? playlist.url ?? ''
),
};
}
/**
* Whether a playlist should use the full-portal auth lifecycle
* (handshake, Bearer token, watchdog).