fix(nav): the address follows the view through overlays, reloads and Back (review round 1)
- A URL mirror names the view again on every entry Back or Forward lands on, so a change made under a dialog, a drawer or a sub-view is not undone by the next reload. - A view pushed from the entry a reload under a dialog started from no longer inherits its overlay mark; a reload under two overlays closes onto the page in one step. - The linked player reopens over a live search, gives itself up when its list moves first, and plays alone over an emptied playlist; a capped Files list keeps the link it cannot resolve. - The Feed press over a channel ends the search; leaving a search ends its asked mark; Files and Playlists searches end with their page; the feed always names its view and debounces its search. - Search-box keys are declared per module and kept out of the client log below TRACE. - Writers outside lib/ go through codecs; the URL contract scans computed keys, overlay writers and two-line reads, and holds every page to a bookmark round trip (Config, Activity, Playlists and the Files sort and viewer added).
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// The Files page's address-bar keys: the folder shown (`?folder=`, its encoding in
|
||||
// modules/files/filesContext), the file it turns to once (`?item=`), the name search (`?fq=`) and the
|
||||
// sort (`?fsort=`, always written, lib/columnSort's `none` for the list's own order). Here, beside the
|
||||
// other pages' key lists, so the page's definition can declare them without importing its own folder.
|
||||
// other pages' codecs (lib/<id>UrlState), where the URL contract test reads them all.
|
||||
export const FILES_FOLDER_KEY = "folder";
|
||||
export const FILES_ITEM_KEY = "item";
|
||||
export const FILES_SEARCH_KEY = "fq";
|
||||
@@ -21,6 +21,28 @@ export const FILES_KEYS = [
|
||||
|
||||
export type FilesOpenFile = { open: "view" | "play"; id: number };
|
||||
|
||||
/** The address-bar delta for the list (the page's store): its search, folder and the file it turns to
|
||||
* — each null when not named (`null`: the page is not what the address shows). */
|
||||
export function filesListParams(
|
||||
list: { search: string; folder: string | null; item: number | null } | null,
|
||||
): Record<string, string | null> {
|
||||
return {
|
||||
[FILES_SEARCH_KEY]: list?.search || null,
|
||||
[FILES_FOLDER_KEY]: list?.folder ?? null,
|
||||
[FILES_ITEM_KEY]: list?.item != null ? String(list.item) : null,
|
||||
};
|
||||
}
|
||||
|
||||
/** The address-bar delta for the list's sort (lib/columnSort's encoding, `none` included). */
|
||||
export function filesSortParams(sort: string | null): Record<string, string | null> {
|
||||
return { [FILES_SORT_KEY]: sort };
|
||||
}
|
||||
|
||||
/** What a file open over the list names in its own entry: the viewer's, or the player's. */
|
||||
export function filesOpenParams(file: FilesOpenFile): Record<string, string | null> {
|
||||
return { [file.open === "play" ? FILES_PLAY_KEY : FILES_VIEW_KEY]: String(file.id) };
|
||||
}
|
||||
|
||||
/** The file an address opens over the list (a reload, a bookmark), or null. */
|
||||
export function openFileFrom(params: URLSearchParams): FilesOpenFile | null {
|
||||
for (const [open, key] of [
|
||||
|
||||
Reference in New Issue
Block a user