store cleanup#29012
Conversation
- Fix operator precedence in getTeamRowBadgeCount: reset users count was never added to badge total - Fix coerceAssertionRole: ['admin, owner'] was a single string, not two elements, so admin/owner roles were never coerced to writer - Rename dedupAddingMembeers -> dedupAddingMembers (typo) - Remove redundant `as boolean` casts on false literals
…op updates - Fix onChatSetTeamRetention: logger.error was firing unconditionally even when metas were successfully processed; move into else branch - badgesUpdated: only clear stores with badge > 0 not in new badge list, avoiding O(n) unconditional writes to all conversation stores - updateInboxLayout: skip buildInboxRows when parsed layout is unchanged, preventing redundant full-layout traversal on repeated notifications - Remove 4 redundant `as boolean` casts on boolean literals
… remove dead code
…cate set calls, cache getState
Replace let-flag-set-in-callback patterns (which TypeScript CFA can't track, causing no-unnecessary-condition errors) with .some() checks and size comparisons. Fix prefer-optional-chain in config networkStatus check.
…ss partition Remove debugTodo constant and its unreachable block, drop redundant fullName:undefined default, add maxDate helper to deduplicate max-time logic, replace [...list, item] spreads with push+return (O(n²) → O(n)), replace two filter/reduce passes over data.items with a single partition loop
- Remove finishedTeam/SelectedRole/SendNotification state fields (only used transiently inside finishedTeamBuilding; replaced with locals) - Remove serviceResultCount (set but never read) - finishedTeamBuilding: capture values before set() to avoid post-set get() - resetState: remove redundant ...s spread - closeTeamBuilding: pre-compute routeNames at module level - search: merge two reduce passes into one loop - interestingPersonToUser: username shorthand
…ffect, unify duplicate helpers, prune freshness map
…prune dead aliases
…indirection, fix noErrors double-get
…, remove spurious undefined arg
…, use Object.entries
There was a problem hiding this comment.
Pull request overview
This PR focuses on general cleanup and small refactors across multiple shared Zustand stores (notably FS + convostate), aiming to simplify logic, reduce redundant state updates, and remove unused/duplicate code paths.
Changes:
- Refactors multiple store handlers to reduce redundant updates (e.g., conditional assignments, consolidated updates, simplified loops).
- Cleans up and deduplicates logic in FS subscriptions and other store flows (push, settings pprof actions, people item reduction, etc.).
- Removes unused/legacy fields and typos (e.g., role coercion check, renamed helpers, spelling fixes).
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| shared/team-building/types.tsx | Removes an unused prop from team-building types. |
| shared/stores/users.tsx | Consolidates identify updates and simplifies blocked-user processing. |
| shared/stores/tracker.tsx | Minor cleanup of tracker load/non-user details and assertion storage. |
| shared/stores/teams.tsx | Fixes badge-count math precedence; corrects helper name/typos and role coercion logic. |
| shared/stores/team-building.tsx | Removes unused “finished” state, streamlines close/finish flows and user update derivations. |
| shared/stores/signup.tsx | Removes unused signup fields/dispatch; simplifies success/reset handling. |
| shared/stores/settings.tsx | Factors common pprof “run + wait” logic; updates proxyData locally on successful save. |
| shared/stores/push.native.tsx | Simplifies native permission helpers; centralizes iOS token fetch; small waiting-state cleanup. |
| shared/stores/provision.tsx | Deduplicates cancel helper logic and removes unused store fields. |
| shared/stores/profile.tsx | Import cleanup and minor state update simplification. |
| shared/stores/people.tsx | Refactors item reduction to avoid array spreads; removes debug code; adds small helper. |
| shared/stores/fs.tsx | Refactors history conversion, subscription management, and several state-update loops for clarity. |
| shared/stores/daemon.tsx | Streamlines handshake state updates and removes indirections. |
| shared/stores/crypto.tsx | Reduces redundant encrypt triggering; small cleanup around input/output reset logic. |
| shared/stores/convostate.tsx | Avoids unnecessary record writes when values are unchanged. |
| shared/stores/config.tsx | Consolidates state updates and avoids redundant network/window-state updates. |
| shared/stores/chat.tsx | Reduces unnecessary badge clears and load-more triggers; avoids rebuilding inbox rows when layout unchanged. |
| shared/stores/archive.tsx | Refactors archive helpers and cleanup flows; switches chat job ID generation approach. |
| shared/signup/username.tsx | Updates back-navigation to use resetState after signup store dispatch changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const startChatArchive = (query: T.RPCChat.GetInboxLocalQuery | null, outPath: string) => { | ||
| const f = async () => { | ||
| const jobID = Uint8Array.from([...Array<number>(8)], () => Math.floor(Math.random() * 256)) | ||
| const jobID = crypto.getRandomValues(new Uint8Array(8)) | ||
| const id = uint8ArrayToHex(jobID) | ||
| const actualOutPath = outPath || (isAndroid && fsCacheDir ? `${fsCacheDir}/kbchat-${id}` : '') |
There was a problem hiding this comment.
crypto.getRandomValues assumes a global WebCrypto implementation is available. In React Native (and some Electron/Node contexts) crypto may be undefined, causing a runtime crash when starting a chat archive job. Consider switching to an existing cross-platform ID generator used elsewhere in the app (or adding a guarded fallback) so job ID generation works reliably across mobile + desktop.
crypto.getRandomValues is not reliably available in React Native / Electron / Node contexts. Extract makeUUID into util/uuid so it can be used without stores importing each other, then use it in archive.
No description provided.