Opening a channel kept every key of the page under it (`?q=music&sort=oldest&chan=…`, a sort the channel did not show), and the channel's own tab, sort and content types lived in its state alone, so a reload or a bookmark lost them. Now the channel's address is `channelUrl`: the shell's keys and `chan`, shared by `openChannel` and the channel link's href. The page writes its view (`chtab`, `chsort`, `chtypes`, lib/channelPageUrlState) and reopens it; these are shell keys, cleared by a page switch and by closing it in place. While a channel stands over a page, no module store writes its keys (`urlPage`); Back finds them on the page's own entry. A link written by an older build opens without the page's keys.
10 lines
546 B
TypeScript
10 lines
546 B
TypeScript
import type { Page } from "../../lib/urlState";
|
|
import type { NavigationState } from "./navigationContext";
|
|
|
|
/** The page whose own keys the address bar carries: none while the channel page stands over it, so
|
|
* every module store writes its keys (`useUrlMirror`) only while its page is what the screen shows.
|
|
* A plain function beside the context, not a hook in it: the stores' tests mock that module. */
|
|
export function urlPage(nav: Pick<NavigationState, "page" | "channelView">): Page | null {
|
|
return nav.channelView ? null : nav.page;
|
|
}
|