diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-10-10 12:27:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-10 12:27:32 -0700 |
commit | d68b4ca856098679efa50295b942833f3f8246cf (patch) | |
tree | 11a54f97c16447eee8191f588bb9be90752a98f4 /src | |
parent | 60c0db03f75d7d8d00c42df6ec2b868830f40969 (diff) | |
download | voidsky-d68b4ca856098679efa50295b942833f3f8246cf.tar.zst |
Fix: fetch follows on desktop search for typeahead (#1660)
Diffstat (limited to 'src')
-rw-r--r-- | src/state/models/cache/my-follows.ts | 5 | ||||
-rw-r--r-- | src/view/shell/desktop/Search.tsx | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/state/models/cache/my-follows.ts b/src/state/models/cache/my-follows.ts index 07079b5af..e1e8af509 100644 --- a/src/state/models/cache/my-follows.ts +++ b/src/state/models/cache/my-follows.ts @@ -5,6 +5,7 @@ import { moderateProfile, } from '@atproto/api' import {RootStoreModel} from '../root-store' +import {bundleAsync} from 'lib/async/bundle' const MAX_SYNC_PAGES = 10 const SYNC_TTL = 60e3 * 10 // 10 minutes @@ -56,7 +57,7 @@ export class MyFollowsCache { * Syncs a subset of the user's follows * for performance reasons, caps out at 1000 follows */ - async syncIfNeeded() { + syncIfNeeded = bundleAsync(async () => { if (this.lastSync > Date.now() - SYNC_TTL) { return } @@ -81,7 +82,7 @@ export class MyFollowsCache { } this.lastSync = Date.now() - } + }) getFollowState(did: string): FollowState { if (typeof this.byDid[did] === 'undefined') { diff --git a/src/view/shell/desktop/Search.tsx b/src/view/shell/desktop/Search.tsx index 53a58c39d..caecea4a8 100644 --- a/src/view/shell/desktop/Search.tsx +++ b/src/view/shell/desktop/Search.tsx @@ -22,6 +22,13 @@ export const DesktopSearch = observer(function DesktopSearch() { ) const navigation = useNavigation<NavigationProp>() + // initial setup + React.useEffect(() => { + if (store.me.did) { + autocompleteView.setup() + } + }, [autocompleteView, store.me.did]) + const onChangeQuery = React.useCallback( (text: string) => { setQuery(text) |