forked from tapexyz/tape
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CuratedProfilesProvider and update LatestBytes and Feed components
- Loading branch information
Showing
7 changed files
with
131 additions
and
87 deletions.
There are no files selected for viewing
This file contains 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
27 changes: 27 additions & 0 deletions
27
apps/web/src/components/Common/Providers/CuratedProfilesProvider.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import useCuratedProfiles from '@lib/store/idb/curated' | ||
import { TAPE_CURATOR_ID } from '@tape.xyz/constants' | ||
import type { FollowingRequest } from '@tape.xyz/lens' | ||
import { LimitType, useFollowingQuery } from '@tape.xyz/lens' | ||
|
||
const followingRequest: FollowingRequest = { | ||
for: TAPE_CURATOR_ID, | ||
limit: LimitType.Fifty | ||
} | ||
|
||
const CuratedProfilesProvider = () => { | ||
const setCuratedProfiles = useCuratedProfiles( | ||
(state) => state.setCuratedProfiles | ||
) | ||
|
||
useFollowingQuery({ | ||
variables: { request: followingRequest }, | ||
onCompleted: ({ following }) => { | ||
const followings = following?.items.map((p) => p.id) | ||
setCuratedProfiles(followings) | ||
} | ||
}) | ||
|
||
return null | ||
} | ||
|
||
export default CuratedProfilesProvider |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import createIdbStorage from '@lib/createIdbStorage' | ||
import { LocalIDBStore } from '@tape.xyz/lens/custom-types' | ||
import { create } from 'zustand' | ||
import { persist } from 'zustand/middleware' | ||
|
||
interface State { | ||
curatedProfiles: string[] | ||
setCuratedProfiles: (curatedProfiles: string[]) => void | ||
} | ||
|
||
const useCuratedProfiles = create( | ||
persist<State>( | ||
(set) => ({ | ||
curatedProfiles: [], | ||
setCuratedProfiles: (curatedProfiles) => set({ curatedProfiles }) | ||
}), | ||
{ | ||
name: LocalIDBStore.ALLOWED_TOKENS_STORE, | ||
storage: createIdbStorage() | ||
} | ||
) | ||
) | ||
|
||
export default useCuratedProfiles |
This file contains 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