refactor(web): migrate NEED_REFRESH_APP_LIST_KEY to useLocalStorage/useSetLocalStorage#36908
Merged
Conversation
…seSetLocalStorage Replace direct localStorage.getItem/setItem/removeItem calls for NEED_REFRESH_APP_LIST_KEY with the useLocalStorage and useSetLocalStorage hooks from @/hooks/use-local-storage, following the pattern from issue langgenius#36898. Affected files (9): - hooks/use-import-dsl.ts - app/components/app-sidebar/app-info/use-app-info-actions.ts - app/components/app/create-from-dsl-modal/index.tsx - app/components/app/create-app-modal/index.tsx - app/components/app/create-app-dialog/app-list/index.tsx - app/components/app/switch-app-modal/index.tsx - app/components/apps/app-card.tsx - app/components/apps/list.tsx - app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/card-view.tsx All setItem calls use useSetLocalStorage<string>(key, { raw: true }). list.tsx uses useLocalStorage<string>(key, '0', { raw: true }) for the getItem + removeItem check-and-clear pattern. Closes langgenius#36898
Member
|
I think this changes the behavior of Before this PR, the app list only performed a one-shot check on mount: if (localStorage.getItem(NEED_REFRESH_APP_LIST_KEY) === '1') {
localStorage.removeItem(NEED_REFRESH_APP_LIST_KEY)
refetch()
}After the change, const [needRefresh, setNeedRefresh] = useLocalStorage<string>(NEED_REFRESH_APP_LIST_KEY, '0', { raw: true })That changes two things:
The writer-side replacements with |
Keep the one-shot read/remove pattern for NEED_REFRESH_APP_LIST_KEY
in list.tsx — it's a refresh signal, not a persisted UI preference.
useLocalStorage writes default '0' and subscribes to live updates, which
adds an unintended refetch path on top of the existing onRefresh={refetch}.
Writer-side useSetLocalStorage replacements are kept as-is.
See: langgenius#36908 (comment)
- list.tsx: use useLocalStorage with undefined serverValue to avoid writing default '0', useEffect with [] deps for mount-only check - Fix import sort: use-local-storage before relative imports and after @/context/* imports
This reverts commit eafdee1.
lyzno1
approved these changes
Jun 2, 2026
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.
Summary
Migrates all direct
localStorage.getItem/setItem/removeItemcalls forNEED_REFRESH_APP_LIST_KEYtouseLocalStorageanduseSetLocalStoragehooks from@/hooks/use-local-storage.This is part of the broader refactor tracked in #36898 — one storage concern at a time.
Changes
9 source files touched, all using the same
{ raw: true }option for raw string storage:Setter-only (useSetLocalStorage)
hooks/use-import-dsl.ts— 2 occurrencesapp/components/app-sidebar/app-info/use-app-info-actions.tsapp/components/app/create-from-dsl-modal/index.tsx— 2 occurrencesapp/components/app/create-app-modal/index.tsxapp/components/app/create-app-dialog/app-list/index.tsxapp/components/app/switch-app-modal/index.tsxapp/components/apps/app-card.tsxapp/(commonLayout)/app/(appDetailLayout)/[appId]/overview/card-view.tsxGetter + remover (useLocalStorage)
app/components/apps/list.tsx— migrated thegetItem+removeItemcheck-and-clear pattern touseLocalStorage<string>(key, '0', { raw: true }), callingsetNeedRefresh(null)to clear.Checklist
localStorage.*NEED_REFRESH_APP_LIST_KEYreferences in source files have been migratedPart of #36898