refactor(api): honest FeedResponse; derive pageTitleKey from the registry (R7 S3a·2-3)
- FeedResponse claimed a required `limit`, but /api/search/youtube never returns it (only /api/feed does) and nothing in the app reads it. Drop the field so searchYoutube's Promise<FeedResponse> stops lying; documented for re-add if a consumer appears. - pageMeta's hand-written 13-case Page->title switch now derives from the ModuleDef registry via a new optional `titleKey` (the longer tab title, e.g. "Channel manager"; falls back to the short nav labelKey). A new page is one touch (add it to MODULES) instead of also editing a switch. A test pins all 13 title keys byte-identical to the old switch (suite 74).
This commit is contained in:
@@ -1,36 +1,12 @@
|
||||
import type { Page } from "./urlState";
|
||||
import { moduleDef } from "./modules";
|
||||
|
||||
// The i18n key for a page's human title — shared by the top-bar header and the browser tab title
|
||||
// so the two never drift. Keep in sync with the nav modules in NavSidebar / App's page switch.
|
||||
// The i18n key for a page's human title — shared by the top-bar header and the browser tab title so
|
||||
// the two never drift. Derived from the single ModuleDef registry (modules.ts): a module's optional
|
||||
// `titleKey` is the longer, descriptive tab title (e.g. "Channel manager"), falling back to its
|
||||
// short nav `labelKey` when the two are the same. Registering a new Page is then one touch (add it
|
||||
// to MODULES) instead of also editing a switch here.
|
||||
export function pageTitleKey(page: Page): string {
|
||||
switch (page) {
|
||||
case "feed":
|
||||
return "header.account.feed";
|
||||
case "channels":
|
||||
return "header.channelManager";
|
||||
case "playlists":
|
||||
return "header.account.playlists";
|
||||
case "notifications":
|
||||
return "inbox.navLabel";
|
||||
case "messages":
|
||||
return "messages.navLabel";
|
||||
case "downloads":
|
||||
return "downloads.navLabel";
|
||||
case "stats":
|
||||
return "header.usageStats";
|
||||
case "plex":
|
||||
return "plex.navLabel";
|
||||
case "scheduler":
|
||||
return "header.scheduler";
|
||||
case "config":
|
||||
return "header.configuration";
|
||||
case "users":
|
||||
return "header.users";
|
||||
case "audit":
|
||||
return "audit.title";
|
||||
case "settings":
|
||||
return "settings.title";
|
||||
default:
|
||||
return "header.account.feed";
|
||||
}
|
||||
const def = moduleDef(page);
|
||||
return def.titleKey ?? def.labelKey;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user