Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Composer/packages/client/src/utils/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,17 @@ export const useLinks = () => {
};

export const useRouterCache = (to: string) => {
const projectId = useRecoilValue(currentProjectIdState);
Comment thread
liweitian marked this conversation as resolved.
Outdated
const [state, setState] = useState(routerCache.getAll());
const { topLinks, bottomLinks } = useLinks();
const linksRef = useRef(topLinks.concat(bottomLinks));
linksRef.current = topLinks.concat(bottomLinks);

useEffect(() => {
routerCache.cleanAll();
setState({});
}, [projectId]);

useEffect(() => {
globalHistory.listen(({ location }) => {
const links = linksRef.current;
Expand Down
5 changes: 5 additions & 0 deletions Composer/packages/client/src/utils/routerCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class RouterCache {
this._all[linkTo] = uri;
this.storage.set(KEY, this._all);
}

cleanAll() {
this._all = {};
this.storage.set(KEY, this._all);
}
}

export default new RouterCache();