feat: sync read/unread state to backend with persistent device ID
- APIClient: generate and persist a stable device UUID (jarvis.device.id in UserDefaults); attach as X-Jarvis-Device-Id header on every request - Add markStoryRead / markStoryUnread — POST/DELETE /stories/:id/read with device_id, read_at, and source fields - Wire both calls into all three read-toggle sites: SignalFeedView, ArticleReaderView, StoryDetailView - Add postVoid helper for fire-and-forget POST calls (no response body needed) - Pass include_read param on stories fetch for future server-side filtering - CacheMaintenance: recentHours 84→72 (mirrors backend 72h story window); markerHours 96→192 so read suppression survives a full weekly news cycle Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -431,8 +431,10 @@ struct ArticleReaderView: View {
|
||||
if let row = (try? modelContext.fetch(
|
||||
FetchDescriptor<ReadStory>(predicate: #Predicate { $0.id == id })))?.first {
|
||||
modelContext.delete(row)
|
||||
Task { try? await APIClient.shared.markStoryUnread(id: id) }
|
||||
} else {
|
||||
modelContext.insert(ReadStory(id: id))
|
||||
Task { try? await APIClient.shared.markStoryRead(id: id) }
|
||||
}
|
||||
try? modelContext.save()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user