diff --git a/src/lib/api/search.ts b/src/lib/api/search.ts index 589c5592c4..d1324abfe5 100644 --- a/src/lib/api/search.ts +++ b/src/lib/api/search.ts @@ -4,6 +4,7 @@ */ import {AppBskyFeedPost} from '@atproto/api' import {SEARCH_HOST} from 'lib/constants' +import {RootStoreModel} from 'state/index' export interface ProfileSearchItem { $type: string @@ -31,15 +32,19 @@ export interface PostSearchItem { } export async function searchProfiles( + rootStore: RootStoreModel, query: string, ): Promise { - const host = SEARCH_HOST(this.rootStore.session.currentSession?.service || '') + const host = SEARCH_HOST(rootStore.session.currentSession?.service || '') const endpoint = `${host}/search/profiles` return await doFetch(endpoint, query) } -export async function searchPosts(query: string): Promise { - const host = SEARCH_HOST(this.rootStore.session.currentSession?.service || '') +export async function searchPosts( + rootStore: RootStoreModel, + query: string, +): Promise { + const host = SEARCH_HOST(rootStore.session.currentSession?.service || '') const endpoint = `${host}/search/posts` return await doFetch(endpoint, query) } diff --git a/src/state/models/ui/search.ts b/src/state/models/ui/search.ts index 4ab9db5135..0665c35a55 100644 --- a/src/state/models/ui/search.ts +++ b/src/state/models/ui/search.ts @@ -27,8 +27,8 @@ export class SearchUIModel { this.isProfilesLoading = true const [postsSearch, profilesSearch] = await Promise.all([ - searchPosts(q).catch(_e => []), - searchProfiles(q).catch(_e => []), + searchPosts(this.rootStore, q).catch(_e => []), + searchProfiles(this.rootStore, q).catch(_e => []), ]) let posts: AppBskyFeedDefs.PostView[] = []