Cleaner sidebar layout (#9603)

This commit is contained in:
Alex Benzer
2026-01-09 14:13:43 -08:00
committed by GitHub
parent 966ae68dd2
commit c4fd9980cc
10 changed files with 422 additions and 129 deletions
+45
View File
@@ -4,12 +4,14 @@ import {
type AppBskyActorGetProfile,
type AppBskyActorGetProfiles,
type AppBskyActorProfile,
type AppBskyGraphGetFollows,
AtUri,
type BskyAgent,
type ComAtprotoRepoUploadBlob,
type Un$Typed,
} from '@atproto/api'
import {
type InfiniteData,
keepPreviousData,
type QueryClient,
useMutation,
@@ -26,6 +28,7 @@ import {type Shadow} from '#/state/cache/types'
import {type ImageMeta} from '#/state/gallery'
import {STALE} from '#/state/queries'
import {resetProfilePostsQueries} from '#/state/queries/post-feed'
import {RQKEY as PROFILE_FOLLOWS_RQKEY} from '#/state/queries/profile-follows'
import {
unstableCacheProfileView,
useUnstableProfileViewCache,
@@ -247,6 +250,7 @@ export function useProfileFollowMutationQueue(
) {
const agent = useAgent()
const queryClient = useQueryClient()
const {currentAccount} = useSession()
const did = profile.did
const initialFollowingUri = profile.viewer?.following
const followMutation = useProfileFollowMutation(
@@ -283,6 +287,47 @@ export function useProfileFollowMutationQueue(
followingUri: finalFollowingUri,
})
// Optimistically update profile follows cache for avatar displays
if (currentAccount?.did) {
type FollowsQueryData =
InfiniteData<AppBskyGraphGetFollows.OutputSchema>
queryClient.setQueryData<FollowsQueryData>(
PROFILE_FOLLOWS_RQKEY(currentAccount.did),
old => {
if (!old?.pages?.[0]) return old
if (finalFollowingUri) {
// Add the followed profile to the beginning
const alreadyExists = old.pages[0].follows.some(
f => f.did === profile.did,
)
if (alreadyExists) return old
return {
...old,
pages: [
{
...old.pages[0],
follows: [
profile as AppBskyActorDefs.ProfileView,
...old.pages[0].follows,
],
},
...old.pages.slice(1),
],
}
} else {
// Remove the unfollowed profile
return {
...old,
pages: old.pages.map(page => ({
...page,
follows: page.follows.filter(f => f.did !== profile.did),
})),
}
}
},
)
}
if (finalFollowingUri) {
agent.app.bsky.graph
.getSuggestedFollowsByActor({