Found while implementing #105 (see PR #107), which fixed the same class of bug in the other
direction.
The problem
FeedView.deleteMessage removes the message from the view's private @State private var messages
working copy, but never from AppDataStore.feedMessages — and therefore never from the persisted
feed cache that AppDataStore writes.
Consequence: the row disappears from the screen, and then comes back — on the next launch that
reads the cache, or any path that re-seeds the view from the store — until a live fetch happens to
replace the page. The server delete succeeds; only the local cache is wrong.
This is the mirror of the staleness #107 fixed for edits, where an edited post updated only the
view's copy and left the store holding the old text.
Why it wasn't fixed in #107
#107 was scoped to in-place row updates. Delete is a different operation with its own question
(below), and folding it in would have mixed two behaviours in one PR.
Build this
Acceptance criteria
Files: Views/FeedView.swift, Services/AppDataStore.swift, and the other delete call sites.
Found while implementing #105 (see PR #107), which fixed the same class of bug in the other
direction.
The problem
FeedView.deleteMessageremoves the message from the view's private@State private var messagesworking copy, but never from
AppDataStore.feedMessages— and therefore never from the persistedfeed cache that
AppDataStorewrites.Consequence: the row disappears from the screen, and then comes back — on the next launch that
reads the cache, or any path that re-seeds the view from the store — until a live fetch happens to
replace the page. The server delete succeeds; only the local cache is wrong.
This is the mirror of the staleness #107 fixed for edits, where an edited post updated only the
view's copy and left the store holding the old text.
Why it wasn't fixed in #107
#107 was scoped to in-place row updates. Delete is a different operation with its own question
(below), and folding it in would have mixed two behaviours in one PR.
Build this
AppDataStore.removeFeedMessage(id:)— mirroring theupdateFeedMessage(_:)added in fix(feed): reconcile in-place row updates in the feed #107,persisting the cache the same way, and a safe no-op for an unknown id.
FeedView.deleteMessagealongside the existing local removal.does the server cascade and the next fetch settle it?
MessagehasparentIdand the backendcascades on delete (
onDelete: Cascadeinmodel Message), so leaving orphans in the cacheuntil the next fetch may be acceptable. Worth one deliberate decision rather than an accident.
MessageDetailView,MessageThreadViewandMessageReplyTreeall delete messages.Acceptance criteria
feedMessagesand from the persisted cache; unknown id is ano-op.
Files:
Views/FeedView.swift,Services/AppDataStore.swift, and the other delete call sites.