2026-06-15 00:30:34 +02:00
|
|
|
import { useTranslation } from "react-i18next";
|
2026-06-29 02:01:44 +02:00
|
|
|
import { Library, Search, User, Youtube } from "lucide-react";
|
2026-06-11 02:19:47 +02:00
|
|
|
import type { FeedFilters, Me } from "../lib/api";
|
feat(m5a): channel manager, tabbed settings panel, per-user sync status
Backend: /api/channels (list + PATCH priority/hidden + attach/detach user tags),
user-tag CRUD on /api/tags, /api/sync/my-status (per-user channel sync counts).
Frontend: feed|channels page nav (URL-synced) from the account menu; a slide-in
tabbed Settings panel (Appearance, Notifications=6b sound+duration, Sync status +
actions + admin pause/resume, Account); a channel manager with priority, hide,
per-channel user tags, sync badges and 'view in feed'. Notifications now honor the
configurable sound + auto-dismiss settings.
2026-06-11 20:45:48 +02:00
|
|
|
import type { Page } from "../lib/urlState";
|
2026-06-11 04:15:25 +02:00
|
|
|
import SyncStatus from "./SyncStatus";
|
2026-06-11 02:19:47 +02:00
|
|
|
|
2026-06-16 00:42:23 +02:00
|
|
|
// Contextual top bar. Primary navigation + account now live in the left NavSidebar; the
|
|
|
|
|
// header carries the global sync status, the feed's scope toggle + search (or the current
|
|
|
|
|
// page title), the language switcher and the notification bell.
|
2026-06-11 02:19:47 +02:00
|
|
|
export default function Header({
|
|
|
|
|
me,
|
|
|
|
|
filters,
|
|
|
|
|
setFilters,
|
feat(m5a): channel manager, tabbed settings panel, per-user sync status
Backend: /api/channels (list + PATCH priority/hidden + attach/detach user tags),
user-tag CRUD on /api/tags, /api/sync/my-status (per-user channel sync counts).
Frontend: feed|channels page nav (URL-synced) from the account menu; a slide-in
tabbed Settings panel (Appearance, Notifications=6b sound+duration, Sync status +
actions + admin pause/resume, Account); a channel manager with priority, hide,
per-channel user tags, sync badges and 'view in feed'. Notifications now honor the
configurable sound + auto-dismiss settings.
2026-06-11 20:45:48 +02:00
|
|
|
page,
|
2026-06-14 07:08:59 +02:00
|
|
|
onGoToFullHistory,
|
2026-06-29 02:01:44 +02:00
|
|
|
onYtSearch,
|
2026-06-11 02:19:47 +02:00
|
|
|
}: {
|
|
|
|
|
me: Me;
|
|
|
|
|
filters: FeedFilters;
|
|
|
|
|
setFilters: (f: FeedFilters) => void;
|
feat(m5a): channel manager, tabbed settings panel, per-user sync status
Backend: /api/channels (list + PATCH priority/hidden + attach/detach user tags),
user-tag CRUD on /api/tags, /api/sync/my-status (per-user channel sync counts).
Frontend: feed|channels page nav (URL-synced) from the account menu; a slide-in
tabbed Settings panel (Appearance, Notifications=6b sound+duration, Sync status +
actions + admin pause/resume, Account); a channel manager with priority, hide,
per-channel user tags, sync badges and 'view in feed'. Notifications now honor the
configurable sound + auto-dismiss settings.
2026-06-11 20:45:48 +02:00
|
|
|
page: Page;
|
2026-06-14 07:08:59 +02:00
|
|
|
onGoToFullHistory: () => void;
|
2026-06-29 02:01:44 +02:00
|
|
|
// Trigger a live YouTube search for the current term (hidden for the demo account, which
|
|
|
|
|
// can't spend the shared quota).
|
|
|
|
|
onYtSearch: (q: string) => void;
|
2026-06-11 02:19:47 +02:00
|
|
|
}) {
|
2026-06-17 14:28:29 +02:00
|
|
|
const { t } = useTranslation();
|
2026-06-29 02:01:44 +02:00
|
|
|
const canSearchYt = !me.is_demo;
|
|
|
|
|
const trimmedQ = filters.q.trim();
|
2026-06-15 00:30:34 +02:00
|
|
|
|
2026-06-11 02:19:47 +02:00
|
|
|
return (
|
2026-06-16 01:11:50 +02:00
|
|
|
<header className="glass h-14 shrink-0 border-b border-border flex items-center gap-3 px-4 z-20">
|
2026-06-14 07:08:59 +02:00
|
|
|
<SyncStatus isAdmin={me.role === "admin"} onGoToFullHistory={onGoToFullHistory} />
|
2026-06-11 04:15:25 +02:00
|
|
|
|
2026-06-15 04:06:22 +02:00
|
|
|
{page === "feed" && (
|
|
|
|
|
<div
|
|
|
|
|
className="flex items-center rounded-full border border-border bg-card p-0.5 text-xs shrink-0"
|
|
|
|
|
role="group"
|
|
|
|
|
aria-label={t("header.scope.label")}
|
|
|
|
|
>
|
|
|
|
|
{(["my", "all"] as const).map((s) => (
|
|
|
|
|
<button
|
|
|
|
|
key={s}
|
|
|
|
|
onClick={() => setFilters({ ...filters, scope: s })}
|
|
|
|
|
title={t("header.scope." + s + "Tip")}
|
|
|
|
|
aria-pressed={filters.scope === s}
|
|
|
|
|
className={`inline-flex items-center gap-1 px-2.5 py-1 rounded-full transition ${
|
|
|
|
|
filters.scope === s
|
|
|
|
|
? "bg-accent text-accent-fg"
|
|
|
|
|
: "text-muted hover:text-fg"
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{s === "my" ? (
|
|
|
|
|
<User className="w-3.5 h-3.5" />
|
|
|
|
|
) : (
|
|
|
|
|
<Library className="w-3.5 h-3.5" />
|
|
|
|
|
)}
|
|
|
|
|
<span className="hidden sm:inline">{t("header.scope." + s)}</span>
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
feat(m5a): channel manager, tabbed settings panel, per-user sync status
Backend: /api/channels (list + PATCH priority/hidden + attach/detach user tags),
user-tag CRUD on /api/tags, /api/sync/my-status (per-user channel sync counts).
Frontend: feed|channels page nav (URL-synced) from the account menu; a slide-in
tabbed Settings panel (Appearance, Notifications=6b sound+duration, Sync status +
actions + admin pause/resume, Account); a channel manager with priority, hide,
per-channel user tags, sync badges and 'view in feed'. Notifications now honor the
configurable sound + auto-dismiss settings.
2026-06-11 20:45:48 +02:00
|
|
|
{page === "feed" ? (
|
2026-06-29 02:01:44 +02:00
|
|
|
<div className="flex-1 max-w-xl mx-auto flex items-center gap-2">
|
|
|
|
|
<div className="flex-1 relative">
|
|
|
|
|
<Search className="w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted" />
|
|
|
|
|
<input
|
|
|
|
|
value={filters.q}
|
2026-06-30 01:36:12 +02:00
|
|
|
onChange={(e) => {
|
|
|
|
|
const q = e.target.value;
|
|
|
|
|
// When a search first appears, rank the feed by relevance — set atomically with
|
|
|
|
|
// the query (race-free vs. per-keystroke updates). Only overrides the default
|
|
|
|
|
// "newest" sort; a custom sort the user chose is left alone. Cleared in Feed.
|
|
|
|
|
const startSearch = !filters.q.trim() && !!q.trim() && filters.sort === "newest";
|
|
|
|
|
setFilters({ ...filters, q, ...(startSearch ? { sort: "relevance" } : {}) });
|
|
|
|
|
}}
|
2026-06-29 02:01:44 +02:00
|
|
|
onKeyDown={(e) => {
|
|
|
|
|
// Enter runs a live YouTube search for the typed term (the box itself filters
|
|
|
|
|
// the local catalog as you type; Enter escalates to the YouTube API).
|
|
|
|
|
if (e.key === "Enter" && trimmedQ && canSearchYt) onYtSearch(trimmedQ);
|
|
|
|
|
}}
|
|
|
|
|
placeholder={t("header.searchPlaceholder")}
|
|
|
|
|
className="w-full bg-card border border-border rounded-full pl-9 pr-4 py-2 text-sm outline-none focus:border-accent"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
{trimmedQ && canSearchYt && (
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => onYtSearch(trimmedQ)}
|
|
|
|
|
title={t("header.searchYoutubeTip")}
|
|
|
|
|
className="shrink-0 inline-flex items-center gap-1.5 rounded-full border border-border bg-card px-3 py-2 text-xs font-medium text-muted hover:text-accent hover:border-accent transition"
|
|
|
|
|
>
|
|
|
|
|
<Youtube className="w-4 h-4" />
|
|
|
|
|
<span className="hidden md:inline">{t("header.searchYoutube")}</span>
|
|
|
|
|
</button>
|
|
|
|
|
)}
|
feat(m5a): channel manager, tabbed settings panel, per-user sync status
Backend: /api/channels (list + PATCH priority/hidden + attach/detach user tags),
user-tag CRUD on /api/tags, /api/sync/my-status (per-user channel sync counts).
Frontend: feed|channels page nav (URL-synced) from the account menu; a slide-in
tabbed Settings panel (Appearance, Notifications=6b sound+duration, Sync status +
actions + admin pause/resume, Account); a channel manager with priority, hide,
per-channel user tags, sync badges and 'view in feed'. Notifications now honor the
configurable sound + auto-dismiss settings.
2026-06-11 20:45:48 +02:00
|
|
|
</div>
|
|
|
|
|
) : (
|
2026-06-12 02:47:55 +02:00
|
|
|
<div className="flex-1 text-center text-sm font-semibold">
|
2026-06-15 15:15:56 +02:00
|
|
|
{page === "stats"
|
|
|
|
|
? t("header.usageStats")
|
|
|
|
|
: page === "playlists"
|
|
|
|
|
? t("header.account.playlists")
|
2026-06-16 01:05:05 +02:00
|
|
|
: page === "settings"
|
|
|
|
|
? t("settings.title")
|
2026-06-16 14:38:51 +02:00
|
|
|
: page === "scheduler"
|
|
|
|
|
? t("header.scheduler")
|
2026-06-19 12:23:00 +02:00
|
|
|
: page === "config"
|
|
|
|
|
? t("header.configuration")
|
2026-06-19 14:16:48 +02:00
|
|
|
: page === "users"
|
|
|
|
|
? t("header.users")
|
2026-06-25 22:58:29 +02:00
|
|
|
: page === "notifications"
|
|
|
|
|
? t("inbox.navLabel")
|
|
|
|
|
: page === "messages"
|
|
|
|
|
? t("messages.navLabel")
|
|
|
|
|
: t("header.channelManager")}
|
2026-06-12 02:47:55 +02:00
|
|
|
</div>
|
feat(m5a): channel manager, tabbed settings panel, per-user sync status
Backend: /api/channels (list + PATCH priority/hidden + attach/detach user tags),
user-tag CRUD on /api/tags, /api/sync/my-status (per-user channel sync counts).
Frontend: feed|channels page nav (URL-synced) from the account menu; a slide-in
tabbed Settings panel (Appearance, Notifications=6b sound+duration, Sync status +
actions + admin pause/resume, Account); a channel manager with priority, hide,
per-channel user tags, sync badges and 'view in feed'. Notifications now honor the
configurable sound + auto-dismiss settings.
2026-06-11 20:45:48 +02:00
|
|
|
)}
|
2026-06-11 02:19:47 +02:00
|
|
|
</header>
|
|
|
|
|
);
|
|
|
|
|
}
|