+1
-1
src/components/dialogs/GifSelect.tsx
+1
-1
src/components/dialogs/GifSelect.tsx
+4
src/state/cache/post-shadow.ts
+4
src/state/cache/post-shadow.ts
···
8
8
import EventEmitter from 'eventemitter3'
9
9
10
10
import {batchedUpdates} from '#/lib/batchedUpdates'
11
+
import {findAllPostsInQueryData as findAllPostsInBookmarksQueryData} from '#/state/queries/bookmarks/useBookmarksQuery'
11
12
import {findAllPostsInQueryData as findAllPostsInExploreFeedPreviewsQueryData} from '#/state/queries/explore-feed-previews'
12
13
import {findAllPostsInQueryData as findAllPostsInNotifsQueryData} from '#/state/queries/notifications/feed'
13
14
import {findAllPostsInQueryData as findAllPostsInFeedQueryData} from '#/state/queries/post-feed'
···
188
189
queryClient,
189
190
uri,
190
191
)) {
192
+
yield post
193
+
}
194
+
for (let post of findAllPostsInBookmarksQueryData(queryClient, uri)) {
191
195
yield post
192
196
}
193
197
}
+46
-1
src/state/queries/bookmarks/useBookmarksQuery.ts
+46
-1
src/state/queries/bookmarks/useBookmarksQuery.ts
···
1
1
import {
2
2
type $Typed,
3
3
type AppBskyBookmarkGetBookmarks,
4
-
type AppBskyFeedDefs,
4
+
AppBskyFeedDefs,
5
+
AtUri,
5
6
} from '@atproto/api'
6
7
import {
7
8
type InfiniteData,
···
10
11
useInfiniteQuery,
11
12
} from '@tanstack/react-query'
12
13
14
+
import {
15
+
didOrHandleUriMatches,
16
+
embedViewRecordToPostView,
17
+
getEmbeddedPost,
18
+
} from '#/state/queries/util'
13
19
import {useAgent} from '#/state/session'
20
+
import * as bsky from '#/types/bsky'
14
21
15
22
export const bookmarksQueryKeyRoot = 'bookmarks'
16
23
export const createBookmarksQueryKey = () => [bookmarksQueryKeyRoot]
···
112
119
},
113
120
)
114
121
}
122
+
123
+
export function* findAllPostsInQueryData(
124
+
queryClient: QueryClient,
125
+
uri: string,
126
+
): Generator<AppBskyFeedDefs.PostView, undefined> {
127
+
const queryDatas = queryClient.getQueriesData<
128
+
InfiniteData<AppBskyBookmarkGetBookmarks.OutputSchema>
129
+
>({
130
+
queryKey: [bookmarksQueryKeyRoot],
131
+
})
132
+
const atUri = new AtUri(uri)
133
+
134
+
for (const [_queryKey, queryData] of queryDatas) {
135
+
if (!queryData?.pages) {
136
+
continue
137
+
}
138
+
for (const page of queryData?.pages) {
139
+
for (const bookmark of page.bookmarks) {
140
+
if (
141
+
!bsky.dangerousIsType<AppBskyFeedDefs.PostView>(
142
+
bookmark.item,
143
+
AppBskyFeedDefs.isPostView,
144
+
)
145
+
)
146
+
continue
147
+
148
+
if (didOrHandleUriMatches(atUri, bookmark.item)) {
149
+
yield bookmark.item
150
+
}
151
+
152
+
const quotedPost = getEmbeddedPost(bookmark.item.embed)
153
+
if (quotedPost && didOrHandleUriMatches(atUri, quotedPost)) {
154
+
yield embedViewRecordToPostView(quotedPost)
155
+
}
156
+
}
157
+
}
158
+
}
159
+
}