Skip to content

Bug: deleting a feed post leaves it in the persisted cache — reappears after relaunch #108

Description

@Adron

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

  • AppDataStore.removeFeedMessage(id:) — mirroring the updateFeedMessage(_:) 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.
  • Call it from FeedView.deleteMessage alongside the existing local removal.
  • Decide the reply case: deleting a parent — does the cache need to drop its replies too, or
    does the server cascade and the next fetch settle it? Message has parentId and the backend
    cascades on delete (onDelete: Cascade in model Message), so leaving orphans in the cache
    until the next fetch may be acceptable. Worth one deliberate decision rather than an accident.
  • Check the other delete paths for the same gap — MessageDetailView, MessageThreadView and
    MessageReplyTree all delete messages.

Acceptance criteria

  • A deleted post stays deleted across a relaunch with no network.
  • Unit test: delete removes from feedMessages and from the persisted cache; unknown id is a
    no-op.
  • No regression to the optimistic-removal UX (the row still disappears immediately).

Files: Views/FeedView.swift, Services/AppDataStore.swift, and the other delete call sites.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingws:papercutsW8 — small parity papercuts

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions