From f9c448b0aa21768de509804895c4e34c93fe503b Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Tue, 20 Oct 2026 20:31:18 +0200 Subject: [PATCH] Show comment avatars from newer Invidious versions Newer Invidious returns a single authorThumbnail URL on comments instead of the authorThumbnails array, so every comment fell back to the placeholder avatar. Decode authorThumbnail as a fallback. --- Yattee/Services/API/InvidiousAPI.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Yattee/Services/API/InvidiousAPI.swift b/Yattee/Services/API/InvidiousAPI.swift index c3ab8f8d..1271ab83 100644 --- a/Yattee/Services/API/InvidiousAPI.swift +++ b/Yattee/Services/API/InvidiousAPI.swift @@ -1974,6 +1974,8 @@ private struct InvidiousComment: Decodable, Sendable { let author: String let authorId: String let authorThumbnails: [InvidiousThumbnail]? + /// Newer Invidious versions send a single avatar URL instead of `authorThumbnails`. + let authorThumbnail: String? let authorIsChannelOwner: Bool? let content: String let published: Int64? @@ -1984,6 +1986,17 @@ private struct InvidiousComment: Decodable, Sendable { let creatorHeart: InvidiousCreatorHeart? let replies: InvidiousCommentReplies? + nonisolated private func authorThumbnailURL(baseURL: URL) -> URL? { + guard let authorThumbnail, !authorThumbnail.isEmpty else { return nil } + if authorThumbnail.hasPrefix("//") { + return URL(string: "https:" + authorThumbnail) + } + if authorThumbnail.hasPrefix("/") { + return URL(string: authorThumbnail, relativeTo: baseURL)?.absoluteURL + } + return URL(string: authorThumbnail) + } + nonisolated func toComment(baseURL: URL) -> Comment { Comment( id: commentId, @@ -1991,6 +2004,7 @@ private struct InvidiousComment: Decodable, Sendable { id: authorId, name: author, thumbnailURL: authorThumbnails?.first?.thumbnailURL(baseURL: baseURL) + ?? authorThumbnailURL(baseURL: baseURL) ), content: content, publishedAt: published.map { Date(timeIntervalSince1970: TimeInterval($0)) },