gql-fix
This commit is contained in:
parent
86c10b1667
commit
4f6c0d1a11
|
@ -5,13 +5,17 @@ import { openPage } from '@nanostores/router'
|
|||
|
||||
import styles from './SearchModal.module.scss'
|
||||
import { router, useRouter } from '../../../stores/router'
|
||||
import { hideModal } from '../../../stores/ui'
|
||||
|
||||
export const SearchModal = () => {
|
||||
const { t } = useLocalize()
|
||||
const { changeSearchParams } = useRouter()
|
||||
let qElement: HTMLInputElement | undefined
|
||||
|
||||
const submitQuery = async (ev) => {
|
||||
ev.preventDefault()
|
||||
changeSearchParams({}, true)
|
||||
hideModal()
|
||||
openPage(router, 'search', { q: qElement.value })
|
||||
}
|
||||
return (
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { gql } from '@urql/core'
|
||||
|
||||
export default gql`
|
||||
query LoadSearchQuery($options: LoadShoutsOptions) {
|
||||
load_shouts_search(options: $options) {
|
||||
query LoadSearchQuery($params: LoadShoutsOptions) {
|
||||
load_shouts_search(params: $params) {
|
||||
score
|
||||
title
|
||||
slug
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { PageProps } from './types'
|
||||
|
||||
import { createMemo, createSignal, onCleanup, onMount, Show } from 'solid-js'
|
||||
import { createEffect, createMemo, createSignal, onCleanup, onMount, Show } from 'solid-js'
|
||||
|
||||
import { Loading } from '../components/_shared/Loading'
|
||||
import { PageLayout } from '../components/_shared/PageLayout'
|
||||
|
@ -12,20 +12,18 @@ import { loadShoutsSearch, resetSortedArticles } from '../stores/zine/articles'
|
|||
|
||||
export const SearchPage = (props: PageProps) => {
|
||||
const [isLoaded, setIsLoaded] = createSignal(Boolean(props.searchResults))
|
||||
|
||||
const { t } = useLocalize()
|
||||
|
||||
const { page } = useRouter()
|
||||
|
||||
const { page, searchParams } = useRouter()
|
||||
const q = createMemo(() => page().params['q'] as string)
|
||||
|
||||
onMount(async () => {
|
||||
if (isLoaded()) {
|
||||
return
|
||||
createEffect(async () => {
|
||||
if (isLoaded()) return
|
||||
else if (q() && window) {
|
||||
const text = q() || window.location.href.split('/').pop()
|
||||
// TODO: pagination, load more
|
||||
await loadShoutsSearch({ text, limit: 50, offset: 0 })
|
||||
setIsLoaded(true)
|
||||
}
|
||||
|
||||
await loadShoutsSearch({ text: q(), limit: 50, offset: 0 })
|
||||
setIsLoaded(true)
|
||||
})
|
||||
|
||||
onCleanup(() => resetSortedArticles())
|
||||
|
|
|
@ -67,15 +67,6 @@ export const hideModal = () => {
|
|||
source: null,
|
||||
}
|
||||
|
||||
if (searchParams().modal === 'auth') {
|
||||
if (searchParams().mode === 'confirm-email') {
|
||||
newSearchParams.token = null
|
||||
}
|
||||
newSearchParams.mode = null
|
||||
}
|
||||
|
||||
changeSearchParams(newSearchParams, true)
|
||||
|
||||
setModal(null)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user