mirror of
https://github.com/yattee/yattee.git
synced 2026-11-04 10:57:18 +00:00
Let rows update their counts, drop fake dates, and own failed lookups
MAC6: a snapshot mutation carries its video count back to the list cache. MAC8: playlist rows and cards are Buttons with the context menu attached, so macOS accessibility can reach Edit and Delete. MAC10: a published date stamped with the request's own time is dropped at both API sentinels, and formattedPublishedDate refuses zero-interval output. MAC11: a failed history hydration shows Details unavailable with a Try Again action instead of keeping the raw video ID forever; an empty 200 body is a legible failure.
This commit is contained in:
@@ -111,6 +111,29 @@ struct Video: Identifiable, Codable, Sendable {
|
||||
)
|
||||
}
|
||||
|
||||
/// The same standing-in video under wording that says the metadata could
|
||||
/// not be fetched, for a row whose fetch has definitively failed.
|
||||
///
|
||||
/// Only what is shown changes: the video handed to the player and the queue
|
||||
/// keeps its ID, which is the part that plays.
|
||||
static func metadataUnavailable(for videoID: String, title: String) -> Video {
|
||||
Video(
|
||||
id: .global(videoID),
|
||||
title: title,
|
||||
description: nil,
|
||||
author: Author(id: "", name: ""),
|
||||
duration: 0,
|
||||
publishedAt: nil,
|
||||
publishedText: nil,
|
||||
viewCount: nil,
|
||||
likeCount: nil,
|
||||
thumbnails: [],
|
||||
isLive: false,
|
||||
isUpcoming: false,
|
||||
scheduledStartTime: nil
|
||||
)
|
||||
}
|
||||
|
||||
/// Whether the title is only the video's own ID standing in for one.
|
||||
///
|
||||
/// Anything showing this video beside details it fetched itself should
|
||||
@@ -166,8 +189,13 @@ struct Video: Identifiable, Codable, Sendable {
|
||||
}
|
||||
|
||||
/// Formatted published date, preferring parsed Date over API-provided text.
|
||||
///
|
||||
/// A date that would render as "in 0 seconds" is shown as nothing at all:
|
||||
/// it is what an instance sends in place of an upload date it does not
|
||||
/// have, and the metadata line is better one segment short than wrong.
|
||||
var formattedPublishedDate: String? {
|
||||
if let publishedAt {
|
||||
guard !RelativeDateFormatter.isEffectivelyNow(publishedAt) else { return nil }
|
||||
let formatter = RelativeDateTimeFormatter()
|
||||
formatter.unitsStyle = .full
|
||||
return formatter.localizedString(for: publishedAt, relativeTo: Date())
|
||||
|
||||
Reference in New Issue
Block a user