fix(desktop): remember Inbox Show unread only - #6105
Conversation
Leaving Inbox remounts HomeView and used to drop the switch back to off. Persist it in localStorage so the next visit keeps the filter. Signed-off-by: Trevor P <trev2005@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e29967089a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| export function readInboxUnreadOnlyPreference(): boolean { | ||
| if (memory !== null) return memory; | ||
| const raw = storage()?.getItem(INBOX_UNREAD_ONLY_KEY); |
There was a problem hiding this comment.
Make the preference read throw-safe
When WKWebView denies website-data access, retrieving window.localStorage may succeed while getItem throws SecurityError; this call is outside the try and runs in the useState initializer, so opening Home sends the entire app to the root failure splash on every mount. Use the existing getStorageItem helper from desktop/src/shared/lib/safeStorage.ts (or catch the read itself) so this preference falls back to false as intended.
Useful? React with 👍 / 👎.
Summary
Inbox Show unread only reset every time you left and came back, because
HomeViewremounts withuseState(false).Persist the switch in
localStorage(buzz.desktop.inbox-unread-only) and read it on mount. An in-memory cache covers the same session if storage is unavailable.Test
desktop/src/features/home/lib/inboxUnreadOnlyPreference.test.mjsSmall UX. No protocol change. Take it or leave it.