+
diff --git a/src/pages/search.page.tsx b/src/pages/search.page.tsx
index d7a72e3a..9d1e5d2a 100644
--- a/src/pages/search.page.tsx
+++ b/src/pages/search.page.tsx
@@ -8,7 +8,7 @@ import { SearchView } from '../components/Views/Search'
import { useLocalize } from '../context/localize'
import { ReactionsProvider } from '../context/reactions'
import { useRouter } from '../stores/router'
-import { loadShouts, resetSortedArticles } from '../stores/zine/articles'
+import { loadShoutsSearch, resetSortedArticles } from '../stores/zine/articles'
export const SearchPage = (props: PageProps) => {
const [isLoaded, setIsLoaded] = createSignal(Boolean(props.searchResults))
@@ -24,7 +24,7 @@ export const SearchPage = (props: PageProps) => {
return
}
- await loadShouts({ filters: { title: q(), body: q() }, limit: 50, offset: 0 })
+ await loadShoutsSearch({ text: q(), limit: 50, offset: 0 })
setIsLoaded(true)
})
diff --git a/src/stores/zine/articles.ts b/src/stores/zine/articles.ts
index 6bfcfd2e..3d5af1a3 100644
--- a/src/stores/zine/articles.ts
+++ b/src/stores/zine/articles.ts
@@ -1,4 +1,10 @@
-import type { Author, Shout, ShoutInput, LoadShoutsOptions } from '../../graphql/schema/core.gen'
+import type {
+ Author,
+ Shout,
+ ShoutInput,
+ LoadShoutsOptions,
+ QueryLoad_Shouts_SearchArgs,
+} from '../../graphql/schema/core.gen'
import { createLazyMemo } from '@solid-primitives/memo'
import { createSignal } from 'solid-js'
@@ -168,6 +174,23 @@ export const loadMyFeed = async (
return { hasMore, newShouts }
}
+export const loadShoutsSearch = async (
+ options: QueryLoad_Shouts_SearchArgs,
+): Promise<{ hasMore: boolean; newShouts: Shout[] }> => {
+ options.limit += 1
+ const newShouts = await apiClient.getShoutsSearch(options)
+ const hasMore = newShouts ?? newShouts.length === options.limit + 1
+
+ if (hasMore) {
+ newShouts.splice(-1)
+ }
+
+ addArticles(newShouts)
+ addSortedArticles(newShouts)
+
+ return { hasMore, newShouts }
+}
+
export const resetSortedArticles = () => {
setSortedArticles([])
}