-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9849a46
commit fdb998a
Showing
15 changed files
with
238 additions
and
164 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
Binary file not shown.
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,31 @@ | ||
import { baseApiUrl } from '@mobile/constants/api'; | ||
import { FeedApiResponse } from '@shared/types/api'; | ||
import { useQueryClient, useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
function buildFeedKey({ fid }: { fid: string }) { | ||
return ['feed', fid]; | ||
} | ||
|
||
function buildFeedFetcher({ fid }: { fid: string }) { | ||
return async (): Promise<FeedApiResponse> => { | ||
const res = await fetch(`${baseApiUrl}/feed/${fid}`); | ||
return res.json(); | ||
}; | ||
} | ||
|
||
export function useFeed({ fid }: { fid: string }) { | ||
return useSuspenseQuery({ | ||
queryKey: buildFeedKey({ fid }), | ||
queryFn: buildFeedFetcher({ fid }), | ||
}).data; | ||
} | ||
|
||
export function useFetchFeed() { | ||
const queryClient = useQueryClient(); | ||
|
||
return async ({ fid }: { fid: string }) => { | ||
const data = buildFeedFetcher({ fid })(); | ||
queryClient.setQueryData(buildFeedKey({ fid }), data); | ||
return data; | ||
}; | ||
} |
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,31 @@ | ||
import { baseApiUrl } from '@mobile/constants/api'; | ||
import { ProfileApiResponse } from '@shared/types/api'; | ||
import { useQueryClient, useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
function buildProfileKey({ fid }: { fid: string }) { | ||
return ['profile', fid]; | ||
} | ||
|
||
function buildProfileFetcher({ fid }: { fid: string }) { | ||
return async (): Promise<ProfileApiResponse> => { | ||
const res = await fetch(`${baseApiUrl}/profiles/${fid}`); | ||
return res.json(); | ||
}; | ||
} | ||
|
||
export function useProfile({ fid }: { fid: string }) { | ||
return useSuspenseQuery({ | ||
queryKey: buildProfileKey({ fid }), | ||
queryFn: buildProfileFetcher({ fid }), | ||
}).data; | ||
} | ||
|
||
export function useFetchProfile() { | ||
const queryClient = useQueryClient(); | ||
|
||
return async ({ fid }: { fid: string }) => { | ||
const data = buildProfileFetcher({ fid })(); | ||
queryClient.setQueryData(buildProfileKey({ fid }), data); | ||
return data; | ||
}; | ||
} |
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,31 @@ | ||
import { baseApiUrl } from '@mobile/constants/api'; | ||
import { ProfileCastsApiResponse } from '@shared/types/api'; | ||
import { useQueryClient, useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
function buildProfileCastsKey({ fid }: { fid: string }) { | ||
return ['profileCasts', fid]; | ||
} | ||
|
||
function buildProfileCastsFetcher({ fid }: { fid: string }) { | ||
return async (): Promise<ProfileCastsApiResponse> => { | ||
const res = await fetch(`${baseApiUrl}/profiles/${fid}/casts`); | ||
return res.json(); | ||
}; | ||
} | ||
|
||
export function useProfileCasts({ fid }: { fid: string }) { | ||
return useSuspenseQuery({ | ||
queryKey: buildProfileCastsKey({ fid }), | ||
queryFn: buildProfileCastsFetcher({ fid }), | ||
}).data; | ||
} | ||
|
||
export function useFetchProfileCasts() { | ||
const queryClient = useQueryClient(); | ||
|
||
return async ({ fid }: { fid: string }) => { | ||
const data = buildProfileCastsFetcher({ fid })(); | ||
queryClient.setQueryData(buildProfileCastsKey({ fid }), data); | ||
return data; | ||
}; | ||
} |
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
File renamed without changes.
File renamed without changes.
Oops, something went wrong.