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 styles from './SearchModal.module.scss'
|
||||||
import { router, useRouter } from '../../../stores/router'
|
import { router, useRouter } from '../../../stores/router'
|
||||||
|
import { hideModal } from '../../../stores/ui'
|
||||||
|
|
||||||
export const SearchModal = () => {
|
export const SearchModal = () => {
|
||||||
const { t } = useLocalize()
|
const { t } = useLocalize()
|
||||||
|
const { changeSearchParams } = useRouter()
|
||||||
let qElement: HTMLInputElement | undefined
|
let qElement: HTMLInputElement | undefined
|
||||||
|
|
||||||
const submitQuery = async (ev) => {
|
const submitQuery = async (ev) => {
|
||||||
ev.preventDefault()
|
ev.preventDefault()
|
||||||
|
changeSearchParams({}, true)
|
||||||
|
hideModal()
|
||||||
openPage(router, 'search', { q: qElement.value })
|
openPage(router, 'search', { q: qElement.value })
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { gql } from '@urql/core'
|
import { gql } from '@urql/core'
|
||||||
|
|
||||||
export default gql`
|
export default gql`
|
||||||
query LoadSearchQuery($options: LoadShoutsOptions) {
|
query LoadSearchQuery($params: LoadShoutsOptions) {
|
||||||
load_shouts_search(options: $options) {
|
load_shouts_search(params: $params) {
|
||||||
score
|
score
|
||||||
title
|
title
|
||||||
slug
|
slug
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { PageProps } from './types'
|
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 { Loading } from '../components/_shared/Loading'
|
||||||
import { PageLayout } from '../components/_shared/PageLayout'
|
import { PageLayout } from '../components/_shared/PageLayout'
|
||||||
|
@ -12,20 +12,18 @@ import { loadShoutsSearch, resetSortedArticles } from '../stores/zine/articles'
|
||||||
|
|
||||||
export const SearchPage = (props: PageProps) => {
|
export const SearchPage = (props: PageProps) => {
|
||||||
const [isLoaded, setIsLoaded] = createSignal(Boolean(props.searchResults))
|
const [isLoaded, setIsLoaded] = createSignal(Boolean(props.searchResults))
|
||||||
|
|
||||||
const { t } = useLocalize()
|
const { t } = useLocalize()
|
||||||
|
const { page, searchParams } = useRouter()
|
||||||
const { page } = useRouter()
|
|
||||||
|
|
||||||
const q = createMemo(() => page().params['q'] as string)
|
const q = createMemo(() => page().params['q'] as string)
|
||||||
|
|
||||||
onMount(async () => {
|
createEffect(async () => {
|
||||||
if (isLoaded()) {
|
if (isLoaded()) return
|
||||||
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())
|
onCleanup(() => resetSortedArticles())
|
||||||
|
|
|
@ -67,15 +67,6 @@ export const hideModal = () => {
|
||||||
source: null,
|
source: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchParams().modal === 'auth') {
|
|
||||||
if (searchParams().mode === 'confirm-email') {
|
|
||||||
newSearchParams.token = null
|
|
||||||
}
|
|
||||||
newSearchParams.mode = null
|
|
||||||
}
|
|
||||||
|
|
||||||
changeSearchParams(newSearchParams, true)
|
|
||||||
|
|
||||||
setModal(null)
|
setModal(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user