Skip to content

fix(#604): a restore keeps its read state and blocklist, nudges expire - #605

Merged
an1ndra merged 2 commits into
Developfrom
fix/604-restore-state
Dec 3, 2026
Merged

an1ndra merged 2 commits into
Developfrom
fix/604-restore-state

Conversation

@an1ndra

@an1ndra an1ndra commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Refs #604 (the restore and nudge parts).

What changed

  • Merge import no longer marks a restored thread unread. It added one unread per inserted message on top of the conversation's restored unread_count, so a read 80-message thread came back as 80 unread. RestoreUnread.toAdd() adds nothing to a conversation the backup inserted whole, and at most the backup's unread count — never more than the messages actually inserted — to one it merged into.
  • A restored blocked sender stays in Spam & blocked. The merge never read conversations.blocked/blocked_at, so the thread landed in the Inbox while its blocklist row was copied. Both columns are carried through an adaptive conversation SELECT (an older backup has neither), and a blocked conversation the merge creates also joins the blocklist. The block cache is cleared after either import mode.
  • Reply nudges expire. The rule had a lower age bound and no ceiling, so enabling the feature surfaced every old unanswered thread. Past a week the message is history; the policy and the row query share MAX_AGE_HOURS.

Not changed

Verification

  • ./gradlew testDebugUnitTest green: RestoreUnreadTest 4, LegacyBackupSchemaTest 5, ReplyNudgePolicyTest 12.
  • scripts/test-restore-state.sh 12/12 on emulator-5558: the half-read thread keeps 2 unread, the read thread stays read, the blocked sender stays blocked and on the blocklist, and all five messages are present.
  • scripts/test-reply-nudge.sh 14/14: the three-month-old thread is not nudged and the existing nudge flow still works.

The merge import added one unread per inserted message on top of the
conversation's restored unread_count, so a thread with 80 read messages came
back as 80 unread. Read state is one number per conversation, so
RestoreUnread.toAdd() adds nothing to a conversation the backup inserted whole
and at most the backup's unread count — never more than the messages the merge
actually inserted — to one it merged into.

The merge never read conversations.blocked, so a restored blocked sender landed
in the Inbox while its blocklist row was copied. Both columns are carried now
through an adaptive conversation SELECT, because blocking postdates soft delete
and an older backup has neither column, and a blocked conversation the merge
creates also reaches the blocklist. The in-process block cache is cleared after
either import mode.

The reply nudge had a lower age bound and no ceiling, so enabling it surfaced
every old unanswered thread. Past a week the message is history; the policy and
the row query share one constant.

Tests: RestoreUnreadTest, LegacyBackupSchemaTest and ReplyNudgePolicyTest.
Scripts test-restore-state.sh (12/12) and test-reply-nudge.sh (14/14) on
emulator-5558. The Trash behaviour is unchanged.
@an1ndra
an1ndra merged commit d7bffe3 into Develop Dec 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant