8zbhzr21j: Restyle post cards, comments and the own-post menu to the redesign spec
This commit is contained in:
+14
-1
@@ -9,6 +9,18 @@ export interface CardMedia {
|
||||
hlsUrl?: string | null;
|
||||
/** Direct progressive MP4 on the feed CDN (videos only). Preferred for playback. */
|
||||
mp4Url?: string | null;
|
||||
/** Video length in whole seconds, when the feed reports it. */
|
||||
durationSeconds?: number | null;
|
||||
}
|
||||
|
||||
/** "m:ss" for a duration in seconds, or null when it is missing or not positive. */
|
||||
export function formatDuration(seconds: number | null | undefined): string | null {
|
||||
if (typeof seconds !== "number" || !Number.isFinite(seconds) || seconds <= 0) return null;
|
||||
const total = Math.round(seconds);
|
||||
const h = Math.floor(total / 3600);
|
||||
const m = Math.floor((total % 3600) / 60);
|
||||
const s = String(total % 60).padStart(2, "0");
|
||||
return h ? `${h}:${String(m).padStart(2, "0")}:${s}` : `${m}:${s}`;
|
||||
}
|
||||
|
||||
export interface CardPost {
|
||||
@@ -92,7 +104,8 @@ function toMedia(raw: unknown): CardMedia[] {
|
||||
const hls = muxHlsUrl(m.hlsUrl);
|
||||
const mp4 = feedMp4Url(m.mp4Url);
|
||||
// Keep a video even with no thumbnail or playable URL yet (just published).
|
||||
out.push({ kind: "video", src: thumb, hlsUrl: hls, mp4Url: mp4 });
|
||||
const dur = typeof m.durationSeconds === "number" ? m.durationSeconds : typeof m.duration === "number" ? m.duration : null;
|
||||
out.push({ kind: "video", src: thumb, hlsUrl: hls, mp4Url: mp4, ...(dur ? { durationSeconds: dur } : {}) });
|
||||
continue;
|
||||
}
|
||||
const src = str(m.imageMediumWebpUrl) ?? str(m.imageMediumUrl) ?? str(m.imageUrl);
|
||||
|
||||
Reference in New Issue
Block a user