refactor(channels): share one ChannelLink + channelYouTubeUrl helper
The "avatar + name + open-on-YouTube" cell and the @handle-or-/channel/<id> URL were copy-pasted across the channel manager, the discovery tab, the subscribe notice and the player. Extract a single ChannelLink component (optional in-app onView, middle-click opens YouTube) and a channelYouTubeUrl helper, and route all four through them. Removes the NameCell / DiscoveryNameCell duplication (the latter introduced with the discovery tab).
This commit is contained in:
parent
795f21a1e1
commit
8c70d72e9a
6 changed files with 91 additions and 72 deletions
|
|
@ -27,6 +27,14 @@ export function relativeTime(iso: string | null): string {
|
|||
return i18n.t("time.monthsAgo", { count: months });
|
||||
}
|
||||
|
||||
// The canonical YouTube URL for a channel: its @handle when known (nicer), else the
|
||||
// /channel/<id> form. One place so every channel link across the app stays consistent.
|
||||
export function channelYouTubeUrl(id: string, handle?: string | null): string {
|
||||
return handle
|
||||
? `https://www.youtube.com/@${handle.replace(/^@/, "")}`
|
||||
: `https://www.youtube.com/channel/${id}`;
|
||||
}
|
||||
|
||||
export function formatDuration(sec: number | null): string {
|
||||
if (sec == null) return "";
|
||||
const h = Math.floor(sec / 3600);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue