-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin' into composer-rq
* origin: Fix poll latest loop (#1901) Handle end of feed (#1898) Refactor onboarding suggested follows (#1897) Update Muted and Blocked accounts screens (react-query refactor) (#1892)
- Loading branch information
Showing
15 changed files
with
461 additions
and
355 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
import {AppBskyGraphGetBlocks} from '@atproto/api' | ||
import {useInfiniteQuery, InfiniteData, QueryKey} from '@tanstack/react-query' | ||
import {useSession} from '../session' | ||
|
||
export const RQKEY = () => ['my-blocked-accounts'] | ||
type RQPageParam = string | undefined | ||
|
||
export function useMyBlockedAccountsQuery() { | ||
const {agent} = useSession() | ||
return useInfiniteQuery< | ||
AppBskyGraphGetBlocks.OutputSchema, | ||
Error, | ||
InfiniteData<AppBskyGraphGetBlocks.OutputSchema>, | ||
QueryKey, | ||
RQPageParam | ||
>({ | ||
queryKey: RQKEY(), | ||
async queryFn({pageParam}: {pageParam: RQPageParam}) { | ||
const res = await agent.app.bsky.graph.getBlocks({ | ||
limit: 30, | ||
cursor: pageParam, | ||
}) | ||
return res.data | ||
}, | ||
initialPageParam: undefined, | ||
getNextPageParam: lastPage => lastPage.cursor, | ||
}) | ||
} |
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,28 @@ | ||
import {AppBskyGraphGetMutes} from '@atproto/api' | ||
import {useInfiniteQuery, InfiniteData, QueryKey} from '@tanstack/react-query' | ||
import {useSession} from '../session' | ||
|
||
export const RQKEY = () => ['my-muted-accounts'] | ||
type RQPageParam = string | undefined | ||
|
||
export function useMyMutedAccountsQuery() { | ||
const {agent} = useSession() | ||
return useInfiniteQuery< | ||
AppBskyGraphGetMutes.OutputSchema, | ||
Error, | ||
InfiniteData<AppBskyGraphGetMutes.OutputSchema>, | ||
QueryKey, | ||
RQPageParam | ||
>({ | ||
queryKey: RQKEY(), | ||
async queryFn({pageParam}: {pageParam: RQPageParam}) { | ||
const res = await agent.app.bsky.graph.getMutes({ | ||
limit: 30, | ||
cursor: pageParam, | ||
}) | ||
return res.data | ||
}, | ||
initialPageParam: undefined, | ||
getNextPageParam: lastPage => lastPage.cursor, | ||
}) | ||
} |
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,75 @@ | ||
import {AppBskyActorGetSuggestions, moderateProfile} from '@atproto/api' | ||
import { | ||
useInfiniteQuery, | ||
useMutation, | ||
InfiniteData, | ||
QueryKey, | ||
} from '@tanstack/react-query' | ||
|
||
import {useSession} from '#/state/session' | ||
import {useModerationOpts} from '#/state/queries/preferences' | ||
|
||
export const suggestedFollowsQueryKey = ['suggested-follows'] | ||
|
||
export function useSuggestedFollowsQuery() { | ||
const {agent, currentAccount} = useSession() | ||
const moderationOpts = useModerationOpts() | ||
|
||
return useInfiniteQuery< | ||
AppBskyActorGetSuggestions.OutputSchema, | ||
Error, | ||
InfiniteData<AppBskyActorGetSuggestions.OutputSchema>, | ||
QueryKey, | ||
string | undefined | ||
>({ | ||
enabled: !!moderationOpts, | ||
queryKey: suggestedFollowsQueryKey, | ||
queryFn: async ({pageParam}) => { | ||
const res = await agent.app.bsky.actor.getSuggestions({ | ||
limit: 25, | ||
cursor: pageParam, | ||
}) | ||
|
||
res.data.actors = res.data.actors | ||
.filter( | ||
actor => !moderateProfile(actor, moderationOpts!).account.filter, | ||
) | ||
.filter(actor => { | ||
const viewer = actor.viewer | ||
if (viewer) { | ||
if ( | ||
viewer.following || | ||
viewer.muted || | ||
viewer.mutedByList || | ||
viewer.blockedBy || | ||
viewer.blocking | ||
) { | ||
return false | ||
} | ||
} | ||
if (actor.did === currentAccount?.did) { | ||
return false | ||
} | ||
return true | ||
}) | ||
|
||
return res.data | ||
}, | ||
initialPageParam: undefined, | ||
getNextPageParam: lastPage => lastPage.cursor, | ||
}) | ||
} | ||
|
||
export function useGetSuggestedFollowersByActor() { | ||
const {agent} = useSession() | ||
|
||
return useMutation({ | ||
mutationFn: async (actor: string) => { | ||
const res = await agent.app.bsky.graph.getSuggestedFollowsByActor({ | ||
actor: actor, | ||
}) | ||
|
||
return res.data | ||
}, | ||
}) | ||
} |
Oops, something went wrong.