From bbce2df01762813af8c8195083b37434597275cd Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 25 Nov 2026 11:06:24 -0800 Subject: [PATCH] Remove optional flatMap from Miniflux models. Make enclosure decoding match other models. Drop unused MinifluxUser.id. Drop unused MinifluxCategory Hashable conformance. --- .../Account/Miniflux/MinifluxAPICaller.swift | 2 +- .../Account/Miniflux/MinifluxCategory.swift | 10 +--------- .../Account/Miniflux/MinifluxEntry.swift | 17 +++++++++-------- .../Sources/Account/Miniflux/MinifluxUser.swift | 1 - .../Account/Miniflux/MinifluxVersion.swift | 5 ++++- .../Miniflux/MinifluxModelDecodingTests.swift | 1 - 6 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Modules/Account/Sources/Account/Miniflux/MinifluxAPICaller.swift b/Modules/Account/Sources/Account/Miniflux/MinifluxAPICaller.swift index 030f4810b..5f32d61b4 100644 --- a/Modules/Account/Sources/Account/Miniflux/MinifluxAPICaller.swift +++ b/Modules/Account/Sources/Account/Miniflux/MinifluxAPICaller.swift @@ -414,7 +414,7 @@ private extension MinifluxAPICaller { /// Nil until `detectServerVersion()` has succeeded once. var detectedVersion: MinifluxVersion? { - accountSettings?.detectedServerVersion.flatMap(MinifluxVersion.init(string:)) + MinifluxVersion(string: accountSettings?.detectedServerVersion) } /// False when the version is unknown, since the fallback works on every supported server. diff --git a/Modules/Account/Sources/Account/Miniflux/MinifluxCategory.swift b/Modules/Account/Sources/Account/Miniflux/MinifluxCategory.swift index 807fbe9cb..dd96e50b8 100644 --- a/Modules/Account/Sources/Account/Miniflux/MinifluxCategory.swift +++ b/Modules/Account/Sources/Account/Miniflux/MinifluxCategory.swift @@ -10,7 +10,7 @@ import Foundation // GET /v1/categories → [{"id":38,"title":"All","user_id":35,"hide_globally":false},...] // A Miniflux category maps one-to-one to an NNW folder. -struct MinifluxCategory: Decodable, Sendable, Hashable { +struct MinifluxCategory: Decodable, Sendable { let categoryID: Int64 let title: String @@ -18,14 +18,6 @@ struct MinifluxCategory: Decodable, Sendable, Hashable { case categoryID = "id" case title } - - static func == (lhs: MinifluxCategory, rhs: MinifluxCategory) -> Bool { - lhs.categoryID == rhs.categoryID - } - - func hash(into hasher: inout Hasher) { - hasher.combine(categoryID) - } } // Used for both category creation and rename — Miniflux takes the same body for both. diff --git a/Modules/Account/Sources/Account/Miniflux/MinifluxEntry.swift b/Modules/Account/Sources/Account/Miniflux/MinifluxEntry.swift index 54fb02a3e..4a824572c 100644 --- a/Modules/Account/Sources/Account/Miniflux/MinifluxEntry.swift +++ b/Modules/Account/Sources/Account/Miniflux/MinifluxEntry.swift @@ -26,11 +26,12 @@ struct MinifluxEntry: Decodable, Sendable { let status: MinifluxEntryStatus? let starred: Bool? - // Miniflux emits ISO8601 dates with fractional seconds and offsets, which JSONDecoder’s - // .iso8601 strategy can’t parse. Rather than lose the whole entry, decode the date as a - // String and let DateParser take care of it — exactly like FeedbinEntry.parsedDatePublished. + /// Decoded as a String, since JSONDecoder’s .iso8601 strategy can’t parse Miniflux’s fractional seconds. var parsedDatePublished: Date? { - datePublished.flatMap { DateParser.date(from: $0) } + guard let datePublished else { + return nil + } + return DateParser.date(from: datePublished) } var attachments: [ParsedAttachment]? { @@ -107,9 +108,9 @@ struct MinifluxEnclosure: Decodable, Sendable { init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - url = try? container.decodeIfPresent(String.self, forKey: .url) - mimeType = try? container.decodeIfPresent(String.self, forKey: .mimeType) - size = try? container.decodeIfPresent(Int.self, forKey: .size) + url = try? container.decode(String.self, forKey: .url) + mimeType = try? container.decode(String.self, forKey: .mimeType) + size = try? container.decode(Int.self, forKey: .size) } } @@ -124,7 +125,7 @@ struct MinifluxEntryIDsResponse: Decodable, Sendable { let entryIDs: [Int64] enum CodingKeys: String, CodingKey { - case total = "total" + case total case entryIDs = "entry_ids" } } diff --git a/Modules/Account/Sources/Account/Miniflux/MinifluxUser.swift b/Modules/Account/Sources/Account/Miniflux/MinifluxUser.swift index 43455f81c..8aafd2d99 100644 --- a/Modules/Account/Sources/Account/Miniflux/MinifluxUser.swift +++ b/Modules/Account/Sources/Account/Miniflux/MinifluxUser.swift @@ -10,6 +10,5 @@ import Foundation // GET /v1/me → {"id":35,"username":"claude","is_admin":false,...} struct MinifluxUser: Decodable, Sendable { - let id: Int64 let username: String } diff --git a/Modules/Account/Sources/Account/Miniflux/MinifluxVersion.swift b/Modules/Account/Sources/Account/Miniflux/MinifluxVersion.swift index ba6def30c..f2b7b0c93 100644 --- a/Modules/Account/Sources/Account/Miniflux/MinifluxVersion.swift +++ b/Modules/Account/Sources/Account/Miniflux/MinifluxVersion.swift @@ -23,7 +23,10 @@ struct MinifluxVersion: Comparable, Sendable { self.components = components } - init?(string: String) { + init?(string: String?) { + guard let string else { + return nil + } let parts = string.split(separator: ".") guard !parts.isEmpty else { return nil diff --git a/Modules/Account/Tests/AccountTests/Miniflux/MinifluxModelDecodingTests.swift b/Modules/Account/Tests/AccountTests/Miniflux/MinifluxModelDecodingTests.swift index 3bd9e0e4e..39ab42b10 100644 --- a/Modules/Account/Tests/AccountTests/Miniflux/MinifluxModelDecodingTests.swift +++ b/Modules/Account/Tests/AccountTests/Miniflux/MinifluxModelDecodingTests.swift @@ -13,7 +13,6 @@ import XCTest func testDecodeUser() throws { let user = try decode(MinifluxUser.self, from: "miniflux_me.json") - XCTAssertEqual(35, user.id) XCTAssertEqual("testuser", user.username) }