Implement data layer infrastructure for Offline Reading feature (Stage 1): - Add OfflineSettings model with 4-hour sync interval - Extend BookmarkEntity with cache fields (htmlContent, cachedDate, imageURLs, etc.) - Add offline cache methods to BookmarksRepository with Kingfisher image prefetching - Extend SettingsRepository with offline settings persistence - Add PSettingsRepository protocol with offline methods - Implement FIFO cleanup for cached articles
31 lines
736 B
Swift
31 lines
736 B
Swift
//
|
|
// OfflineSettings.swift
|
|
// readeck
|
|
//
|
|
// Created by Claude on 08.11.25.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
struct OfflineSettings: Codable {
|
|
var enabled: Bool = true
|
|
var maxUnreadArticles: Double = 20 // Double für Slider (Default: 20 Artikel)
|
|
var saveImages: Bool = false
|
|
var lastSyncDate: Date?
|
|
|
|
var maxUnreadArticlesInt: Int {
|
|
Int(maxUnreadArticles)
|
|
}
|
|
|
|
var shouldSyncOnAppStart: Bool {
|
|
guard enabled else { return false }
|
|
|
|
// Sync if never synced before
|
|
guard let lastSync = lastSyncDate else { return true }
|
|
|
|
// Sync if more than 4 hours since last sync
|
|
let fourHoursAgo = Date().addingTimeInterval(-4 * 60 * 60)
|
|
return lastSync < fourHoursAgo
|
|
}
|
|
}
|