Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[Session] Drill into `getAgent` into `whenAppViewReady` (#3702)

* Drill into whenAppViewReady

(cherry picked from commit e290e5be3df509bdd9d0e626a164996c9dee3636)

* Drill getAgent instead

---------

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>

authored by

Eric Bailey
Dan Abramov
and committed by
GitHub
a69e5679 ec376960

+45 -20
+42 -20
src/state/queries/list.ts
··· 4 4 AppBskyGraphGetList, 5 5 AppBskyGraphList, 6 6 AtUri, 7 + BskyAgent, 7 8 Facet, 8 9 } from '@atproto/api' 9 10 import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query' ··· 85 86 ) 86 87 87 88 // wait for the appview to update 88 - await whenAppViewReady(res.uri, (v: AppBskyGraphGetList.Response) => { 89 - return typeof v?.data?.list.uri === 'string' 90 - }) 89 + await whenAppViewReady( 90 + getAgent, 91 + res.uri, 92 + (v: AppBskyGraphGetList.Response) => { 93 + return typeof v?.data?.list.uri === 'string' 94 + }, 95 + ) 91 96 return res 92 97 }, 93 98 onSuccess() { ··· 150 155 ).data 151 156 152 157 // wait for the appview to update 153 - await whenAppViewReady(res.uri, (v: AppBskyGraphGetList.Response) => { 154 - const list = v.data.list 155 - return ( 156 - list.name === record.name && list.description === record.description 157 - ) 158 - }) 158 + await whenAppViewReady( 159 + getAgent, 160 + res.uri, 161 + (v: AppBskyGraphGetList.Response) => { 162 + const list = v.data.list 163 + return ( 164 + list.name === record.name && list.description === record.description 165 + ) 166 + }, 167 + ) 159 168 return res 160 169 }, 161 170 onSuccess(data, variables) { ··· 220 229 } 221 230 222 231 // wait for the appview to update 223 - await whenAppViewReady(uri, (v: AppBskyGraphGetList.Response) => { 224 - return !v?.success 225 - }) 232 + await whenAppViewReady( 233 + getAgent, 234 + uri, 235 + (v: AppBskyGraphGetList.Response) => { 236 + return !v?.success 237 + }, 238 + ) 226 239 }, 227 240 onSuccess() { 228 241 invalidateMyLists(queryClient) ··· 244 257 await getAgent().unmuteModList(uri) 245 258 } 246 259 247 - await whenAppViewReady(uri, (v: AppBskyGraphGetList.Response) => { 248 - return Boolean(v?.data.list.viewer?.muted) === mute 249 - }) 260 + await whenAppViewReady( 261 + getAgent, 262 + uri, 263 + (v: AppBskyGraphGetList.Response) => { 264 + return Boolean(v?.data.list.viewer?.muted) === mute 265 + }, 266 + ) 250 267 }, 251 268 onSuccess(data, variables) { 252 269 queryClient.invalidateQueries({ ··· 266 283 await getAgent().unblockModList(uri) 267 284 } 268 285 269 - await whenAppViewReady(uri, (v: AppBskyGraphGetList.Response) => { 270 - return block 271 - ? typeof v?.data.list.viewer?.blocked === 'string' 272 - : !v?.data.list.viewer?.blocked 273 - }) 286 + await whenAppViewReady( 287 + getAgent, 288 + uri, 289 + (v: AppBskyGraphGetList.Response) => { 290 + return block 291 + ? typeof v?.data.list.viewer?.blocked === 'string' 292 + : !v?.data.list.viewer?.blocked 293 + }, 294 + ) 274 295 }, 275 296 onSuccess(data, variables) { 276 297 queryClient.invalidateQueries({ ··· 281 302 } 282 303 283 304 async function whenAppViewReady( 305 + getAgent: () => BskyAgent, 284 306 uri: string, 285 307 fn: (res: AppBskyGraphGetList.Response) => boolean, 286 308 ) {
+3
src/state/queries/profile.ts
··· 8 8 AppBskyEmbedRecordWithMedia, 9 9 AppBskyFeedDefs, 10 10 AtUri, 11 + BskyAgent, 11 12 } from '@atproto/api' 12 13 import { 13 14 QueryClient, ··· 154 155 return existing 155 156 }) 156 157 await whenAppViewReady( 158 + getAgent, 157 159 profile.did, 158 160 checkCommitted || 159 161 (res => { ··· 516 518 } 517 519 518 520 async function whenAppViewReady( 521 + getAgent: () => BskyAgent, 519 522 actor: string, 520 523 fn: (res: AppBskyActorGetProfile.Response) => boolean, 521 524 ) {