Skip to content

Commit

Permalink
Fix following/unfollowed DAOs bleeding into other wallets when you sw…
Browse files Browse the repository at this point in the history
…itch wallets. (DA0-DA0#1231)
  • Loading branch information
NoahSaso authored Apr 7, 2023
1 parent 88bc4d3 commit a6bfc70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion packages/stateful/hooks/useFollowingDaos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export const useFollowingDaos = (): UseFollowingDaosReturn => {
// Following API doesn't update right away, so this serves to keep track of
// all successful updates for the current session. This will be reset on page
// refresh.
const setTemporary = useSetRecoilState(temporaryFollowingDaosAtom)
const setTemporary = useSetRecoilState(
temporaryFollowingDaosAtom(walletAddress ?? '')
)

const followingDaosLoading = useCachedLoading(
walletAddress
Expand Down
15 changes: 9 additions & 6 deletions packages/stateful/recoil/selectors/dao/following.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import uniq from 'lodash.uniq'
import { atom, selectorFamily, waitForAll } from 'recoil'
import { atomFamily, selectorFamily, waitForAll } from 'recoil'

import { refreshFollowingDaosAtom } from '@dao-dao/state'
import { DaoDropdownInfo } from '@dao-dao/stateless'
Expand All @@ -14,10 +14,13 @@ import { daoCoreProposalModulesSelector } from './misc'
// session. This will be reset on page refresh. Set this right away so the UI
// can update immediately even if the API takes up to a minute or two. Though
// likely it only takes 10 seconds or so.
export const temporaryFollowingDaosAtom = atom<{
following: string[]
unfollowing: string[]
}>({
export const temporaryFollowingDaosAtom = atomFamily<
{
following: string[]
unfollowing: string[]
},
string
>({
key: 'temporaryFollowingDaos',
default: { following: [], unfollowing: [] },
})
Expand All @@ -34,7 +37,7 @@ export const followingDaosSelector = selectorFamily<
async ({ get }) => {
get(refreshFollowingDaosAtom)

const temporary = get(temporaryFollowingDaosAtom)
const temporary = get(temporaryFollowingDaosAtom(walletAddress))

const response = await fetch(
FOLLOWING_DAOS_API_BASE + `/following/${chainId}/${walletAddress}`
Expand Down

0 comments on commit a6bfc70

Please sign in to comment.