Restore shell sync on browser history

- Re-sync the active shell page on popstate
- Keep React routes like /issues on the React host after back/forward navigation
- Preserve the existing legacy page activation path for non-React routes
pull/388/head
Antti Kettunen 2 weeks ago
parent 538bb9344b
commit 8d6ab4eb74
No known key found for this signature in database
GPG Key ID: C6B2A3D250359BD7

@ -64,6 +64,28 @@ function activateLegacyPath(pathname) {
activatePage(targetPage, { forceReload: true });
}
function syncActivePageFromLocation() {
const router = getWebRouter();
const targetPage = router?.resolvePageId?.(window.location.pathname) || _getPageFromPath(window.location.pathname);
if (!targetPage) return;
if (!isPageAllowed(targetPage)) {
const home = getProfileHomePage();
if (home !== targetPage) {
navigateToPage(home, { replace: true });
}
return;
}
const route = router?.routeManifest?.find((entry) => entry.pageId === targetPage);
if (route?.kind === 'react') {
showReactHost(targetPage);
} else {
showLegacyPage(targetPage);
}
setActivePageChrome(targetPage);
}
const SHELL_BRIDGE_READY_EVENT = 'ss:webui-shell-bridge-ready';
function openDownloadMissingAlbumWorkflow(input) {
@ -130,4 +152,5 @@ window.SoulSyncWebShellBridge = {
},
};
window.addEventListener('popstate', syncActivePageFromLocation);
window.dispatchEvent(new CustomEvent(SHELL_BRIDGE_READY_EVENT));

Loading…
Cancel
Save