mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-10 02:33:04 +02:00
Hook browser back/forward to nav state
Push history on user-initiated navigation so 'Back' moves between views instead of leaving the app. - urlHash: add pushUrlHash/pushSettingsHash (pushState variants) - useConversationRouter: pushState on nav; popstate resolves hash to conversation without re-pushing; switch over if-chain - useAppShell: pushState on settings open; popstate syncs visibility; close via history.back() when we own the entry - Tests: popstate coverage in appStartupHash + useAppShell
This commit is contained in:
@@ -171,9 +171,25 @@ export function updateUrlHash(conv: Conversation | null): void {
|
||||
}
|
||||
}
|
||||
|
||||
// Update URL hash and add a new browser history entry
|
||||
export function pushUrlHash(conv: Conversation | null): void {
|
||||
const newHash = getConversationHash(conv);
|
||||
if (newHash !== window.location.hash) {
|
||||
window.history.pushState(null, '', newHash || window.location.pathname);
|
||||
}
|
||||
}
|
||||
|
||||
export function updateSettingsHash(section: SettingsSection): void {
|
||||
const newHash = getSettingsHash(section);
|
||||
if (newHash !== window.location.hash) {
|
||||
window.history.replaceState(null, '', newHash);
|
||||
}
|
||||
}
|
||||
|
||||
// Push a settings hash as a new browser history entry
|
||||
export function pushSettingsHash(section: SettingsSection): void {
|
||||
const newHash = getSettingsHash(section);
|
||||
if (newHash !== window.location.hash) {
|
||||
window.history.pushState(null, '', newHash);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user