Browse Source

fix: some bugs

imwald
codytseng 6 months ago
parent
commit
be3c0023fe
  1. 2
      src/components/PostEditor/PostContent.tsx
  2. 2
      src/layouts/PrimaryPageLayout/index.tsx
  3. 18
      src/pages/primary/SearchPage/index.tsx
  4. 1
      src/services/post-editor-cache.service.ts

2
src/components/PostEditor/PostContent.tsx

@ -82,7 +82,6 @@ export default function PostContent({ @@ -82,7 +82,6 @@ export default function PostContent({
relays: []
}
)
setSpecifiedRelayUrls(cachedSettings.specifiedRelayUrls)
setAddClientTag(cachedSettings.addClientTag ?? false)
}
return
@ -93,7 +92,6 @@ export default function PostContent({ @@ -93,7 +92,6 @@ export default function PostContent({
isNsfw,
isPoll,
pollCreateData,
specifiedRelayUrls,
addClientTag
}
)

2
src/layouts/PrimaryPageLayout/index.tsx

@ -108,7 +108,7 @@ PrimaryPageLayout.displayName = 'PrimaryPageLayout' @@ -108,7 +108,7 @@ PrimaryPageLayout.displayName = 'PrimaryPageLayout'
export default PrimaryPageLayout
export type TPrimaryPageLayoutRef = {
scrollToTop: () => void
scrollToTop: (behavior?: ScrollBehavior) => void
}
function PrimaryPageTitlebar({

18
src/pages/primary/SearchPage/index.tsx

@ -1,16 +1,25 @@ @@ -1,16 +1,25 @@
import SearchBar, { TSearchBarRef } from '@/components/SearchBar'
import SearchResult from '@/components/SearchResult'
import PrimaryPageLayout from '@/layouts/PrimaryPageLayout'
import PrimaryPageLayout, { TPrimaryPageLayoutRef } from '@/layouts/PrimaryPageLayout'
import { usePrimaryPage } from '@/PageManager'
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 { current, display } = usePrimaryPage()
const [input, setInput] = useState('')
const [searchParams, setSearchParams] = useState<TSearchParams | null>(null)
const searchBarRef = useRef<TSearchBarRef>(null)
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(() => {
if (isActive && !searchParams) {
@ -23,11 +32,12 @@ const SearchPage = forwardRef((_, ref) => { @@ -23,11 +32,12 @@ const SearchPage = forwardRef((_, ref) => {
if (params?.input) {
setInput(params.input)
}
layoutRef.current?.scrollToTop('instant')
}
return (
<PrimaryPageLayout
ref={ref}
ref={layoutRef}
pageName="search"
titlebar={
<SearchBar ref={searchBarRef} onSearch={onSearch} input={input} setInput={setInput} />

1
src/services/post-editor-cache.service.ts

@ -6,7 +6,6 @@ type TPostSettings = { @@ -6,7 +6,6 @@ type TPostSettings = {
isNsfw?: boolean
isPoll?: boolean
pollCreateData?: TPollCreateData
specifiedRelayUrls?: string[]
addClientTag?: boolean
}

Loading…
Cancel
Save