Fix: fetch follows on desktop search for typeahead (#1660)
parent
60c0db03f7
commit
d68b4ca856
|
@ -5,6 +5,7 @@ import {
|
||||||
moderateProfile,
|
moderateProfile,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
import {RootStoreModel} from '../root-store'
|
import {RootStoreModel} from '../root-store'
|
||||||
|
import {bundleAsync} from 'lib/async/bundle'
|
||||||
|
|
||||||
const MAX_SYNC_PAGES = 10
|
const MAX_SYNC_PAGES = 10
|
||||||
const SYNC_TTL = 60e3 * 10 // 10 minutes
|
const SYNC_TTL = 60e3 * 10 // 10 minutes
|
||||||
|
@ -56,7 +57,7 @@ export class MyFollowsCache {
|
||||||
* Syncs a subset of the user's follows
|
* Syncs a subset of the user's follows
|
||||||
* for performance reasons, caps out at 1000 follows
|
* for performance reasons, caps out at 1000 follows
|
||||||
*/
|
*/
|
||||||
async syncIfNeeded() {
|
syncIfNeeded = bundleAsync(async () => {
|
||||||
if (this.lastSync > Date.now() - SYNC_TTL) {
|
if (this.lastSync > Date.now() - SYNC_TTL) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -81,7 +82,7 @@ export class MyFollowsCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastSync = Date.now()
|
this.lastSync = Date.now()
|
||||||
}
|
})
|
||||||
|
|
||||||
getFollowState(did: string): FollowState {
|
getFollowState(did: string): FollowState {
|
||||||
if (typeof this.byDid[did] === 'undefined') {
|
if (typeof this.byDid[did] === 'undefined') {
|
||||||
|
|
|
@ -22,6 +22,13 @@ export const DesktopSearch = observer(function DesktopSearch() {
|
||||||
)
|
)
|
||||||
const navigation = useNavigation<NavigationProp>()
|
const navigation = useNavigation<NavigationProp>()
|
||||||
|
|
||||||
|
// initial setup
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (store.me.did) {
|
||||||
|
autocompleteView.setup()
|
||||||
|
}
|
||||||
|
}, [autocompleteView, store.me.did])
|
||||||
|
|
||||||
const onChangeQuery = React.useCallback(
|
const onChangeQuery = React.useCallback(
|
||||||
(text: string) => {
|
(text: string) => {
|
||||||
setQuery(text)
|
setQuery(text)
|
||||||
|
|
Loading…
Reference in New Issue