Remove optional flatMap from Miniflux models. Make enclosure decoding match other models. Drop unused MinifluxUser.id. Drop unused MinifluxCategory Hashable conformance.

This commit is contained in:
Brent Simmons committed 2026-11-25 11:06:24 -08:00
1 parent fa89d0e00e
commit bbce2df017
6 files changed
+15 -21

No files matched your search

@@ -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.
@@ -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.
@@ -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"
}
}
@@ -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
}
@@ -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
@@ -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)
}