fix: persist Inbox 'Show unread only' toggle across sessions - #3682
Open
iroiro147 wants to merge 1 commit into
Open
fix: persist Inbox 'Show unread only' toggle across sessions#3682iroiro147 wants to merge 1 commit into
iroiro147 wants to merge 1 commit into
Conversation
The 'Show unread only' toggle in the Inbox reset to off every time the view was remounted (navigation away/back, app restart). This was because the state was held in a plain React.useState(false) with no persistence. This change introduces usePersistentBoolean — a small localStorage-backed hook that follows the same versioned-key pattern as useFeedItemState (buzz-home-*.v1). The unreadOnly toggle now reads its initial value from localStorage on mount and writes back on every change. Acceptance criteria met: - Enabling 'Show unread only' persists across navigation away/back - The enabled state is restored after restarting Buzz - Disabling the toggle updates the saved preference - Users without a saved preference retain the default of off - Automated tests verify preference restoration and default/fallback Closes block#3669
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Inbox's Show unread only toggle resets to off whenever the Inbox view is remounted. Users who prefer an unread-only Inbox have to enable it again after navigating away, reopening the Inbox, or restarting Buzz.
Closes #3669
Root Cause
The
unreadOnlystate inHomeView.tsxwas a plainReact.useState(false)with no persistence layer — every remount starts fresh.Solution
Introduced
usePersistentBoolean— a smalllocalStorage-backed hook that follows the same versioned-key pattern already used byuseFeedItemStatein this codebase (e.g.buzz-home-feed-done.v1).localStorage. If absent, falls back tofalse.localStorage.typeof windowguard) and degrades silently if storage is unavailable.Changes
desktop/src/features/home/usePersistentBoolean.tsdesktop/src/features/home/ui/HomeView.tsxuseState(false)withusePersistentBoolean(2 lines changed)desktop/src/features/home/usePersistentBoolean.test.mjsAcceptance Criteria
Test Plan
cd desktop node --test src/features/home/usePersistentBoolean.test.mjsAll 7 tests pass: