fix: some bugs
This commit is contained in:
@@ -82,7 +82,6 @@ export default function PostContent({
|
|||||||
relays: []
|
relays: []
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
setSpecifiedRelayUrls(cachedSettings.specifiedRelayUrls)
|
|
||||||
setAddClientTag(cachedSettings.addClientTag ?? false)
|
setAddClientTag(cachedSettings.addClientTag ?? false)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -93,7 +92,6 @@ export default function PostContent({
|
|||||||
isNsfw,
|
isNsfw,
|
||||||
isPoll,
|
isPoll,
|
||||||
pollCreateData,
|
pollCreateData,
|
||||||
specifiedRelayUrls,
|
|
||||||
addClientTag
|
addClientTag
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ PrimaryPageLayout.displayName = 'PrimaryPageLayout'
|
|||||||
export default PrimaryPageLayout
|
export default PrimaryPageLayout
|
||||||
|
|
||||||
export type TPrimaryPageLayoutRef = {
|
export type TPrimaryPageLayoutRef = {
|
||||||
scrollToTop: () => void
|
scrollToTop: (behavior?: ScrollBehavior) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
function PrimaryPageTitlebar({
|
function PrimaryPageTitlebar({
|
||||||
|
|||||||
@@ -1,16 +1,25 @@
|
|||||||
import SearchBar, { TSearchBarRef } from '@/components/SearchBar'
|
import SearchBar, { TSearchBarRef } from '@/components/SearchBar'
|
||||||
import SearchResult from '@/components/SearchResult'
|
import SearchResult from '@/components/SearchResult'
|
||||||
import PrimaryPageLayout from '@/layouts/PrimaryPageLayout'
|
import PrimaryPageLayout, { TPrimaryPageLayoutRef } from '@/layouts/PrimaryPageLayout'
|
||||||
import { usePrimaryPage } from '@/PageManager'
|
import { usePrimaryPage } from '@/PageManager'
|
||||||
import { TSearchParams } from '@/types'
|
import { TSearchParams } from '@/types'
|
||||||
import { forwardRef, useEffect, useMemo, useRef, useState } from 'react'
|
import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'
|
||||||
|
|
||||||
const SearchPage = forwardRef((_, ref) => {
|
const SearchPage = forwardRef((_, ref) => {
|
||||||
const { current, display } = usePrimaryPage()
|
const { current, display } = usePrimaryPage()
|
||||||
const [input, setInput] = useState('')
|
const [input, setInput] = useState('')
|
||||||
const [searchParams, setSearchParams] = useState<TSearchParams | null>(null)
|
const [searchParams, setSearchParams] = useState<TSearchParams | null>(null)
|
||||||
const searchBarRef = useRef<TSearchBarRef>(null)
|
|
||||||
const isActive = useMemo(() => current === 'search' && display, [current, display])
|
const isActive = useMemo(() => current === 'search' && display, [current, display])
|
||||||
|
const searchBarRef = useRef<TSearchBarRef>(null)
|
||||||
|
const layoutRef = useRef<TPrimaryPageLayoutRef>(null)
|
||||||
|
|
||||||
|
useImperativeHandle(
|
||||||
|
ref,
|
||||||
|
() => ({
|
||||||
|
scrollToTop: (behavior: ScrollBehavior = 'smooth') => layoutRef.current?.scrollToTop(behavior)
|
||||||
|
}),
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isActive && !searchParams) {
|
if (isActive && !searchParams) {
|
||||||
@@ -23,11 +32,12 @@ const SearchPage = forwardRef((_, ref) => {
|
|||||||
if (params?.input) {
|
if (params?.input) {
|
||||||
setInput(params.input)
|
setInput(params.input)
|
||||||
}
|
}
|
||||||
|
layoutRef.current?.scrollToTop('instant')
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PrimaryPageLayout
|
<PrimaryPageLayout
|
||||||
ref={ref}
|
ref={layoutRef}
|
||||||
pageName="search"
|
pageName="search"
|
||||||
titlebar={
|
titlebar={
|
||||||
<SearchBar ref={searchBarRef} onSearch={onSearch} input={input} setInput={setInput} />
|
<SearchBar ref={searchBarRef} onSearch={onSearch} input={input} setInput={setInput} />
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ type TPostSettings = {
|
|||||||
isNsfw?: boolean
|
isNsfw?: boolean
|
||||||
isPoll?: boolean
|
isPoll?: boolean
|
||||||
pollCreateData?: TPollCreateData
|
pollCreateData?: TPollCreateData
|
||||||
specifiedRelayUrls?: string[]
|
|
||||||
addClientTag?: boolean
|
addClientTag?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user