Skip to content

Commit

Permalink
ENG-1 Fixed "My DAOs" menu update issue when DAOs are favorited/unfav…
Browse files Browse the repository at this point in the history
…orited.
  • Loading branch information
John Huang committed Dec 12, 2024
1 parent 55f2429 commit 5f8c02b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"react-router-dom": "^6.22.0",
"remark-gfm": "^4.0.0",
"sonner": "^1.5.0",
"use-between": "^1.3.5",
"viem": "^2.13.1",
"vite": "^5.3.4",
"vite-plugin-checker": "^0.6.4",
Expand Down
11 changes: 10 additions & 1 deletion src/hooks/DAO/loaders/useFavorites.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import { useState } from 'react';
import { useBetween } from 'use-between';
import { Address } from 'viem';
import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider';
import { CacheKeys, CacheExpiry, FavoritesCacheValue } from '../../utils/cache/cacheDefaults';
import { getValue, setValue } from '../../utils/cache/useLocalStorage';

export const useAccountFavorites = () => {
const useSharedAccountFavorites = () => {
const [favoritesList, setFavoritesList] = useState<FavoritesCacheValue[]>(
getValue({ cacheName: CacheKeys.FAVORITES }) || [],
);
return {
favoritesList,
setFavoritesList
};
};

export const useAccountFavorites = () => {
const { favoritesList, setFavoritesList } = useBetween(useSharedAccountFavorites)
const { addressPrefix } = useNetworkConfig();

const toggleFavorite = (address: Address, name: string) => {
Expand Down

0 comments on commit 5f8c02b

Please sign in to comment.