feat: 💨

This commit is contained in:
codytseng 2026-01-01 15:19:45 +08:00
parent 7837d67ecf
commit 7a9c777744
3 changed files with 25 additions and 7 deletions

View file

@ -35,6 +35,7 @@ export default function NormalFeed({
const showKindsFilter = useMemo(() => { const showKindsFilter = useMemo(() => {
return subRequests.every((req) => !req.filter.kinds?.length) return subRequests.every((req) => !req.filter.kinds?.length)
}, [subRequests]) }, [subRequests])
const [trustFilterOpen, setTrustFilterOpen] = useState(false)
const handleListModeChange = (mode: TNoteListMode) => { const handleListModeChange = (mode: TNoteListMode) => {
setListMode(mode) setListMode(mode)
@ -49,6 +50,10 @@ export default function NormalFeed({
noteListRef.current?.scrollToTop() noteListRef.current?.scrollToTop()
} }
const handleTrustFilterOpenChange = (open: boolean) => {
setTrustFilterOpen(open)
}
return ( return (
<> <>
<Tabs <Tabs
@ -78,7 +83,7 @@ export default function NormalFeed({
}} }}
/> />
)} )}
<TrustScoreFilter /> <TrustScoreFilter onOpenChange={handleTrustFilterOpenChange} />
{showKindsFilter && ( {showKindsFilter && (
<KindFilter <KindFilter
showKinds={temporaryShowKinds} showKinds={temporaryShowKinds}
@ -87,6 +92,7 @@ export default function NormalFeed({
)} )}
</> </>
} }
active={trustFilterOpen}
/> />
<div ref={topRef} className="scroll-mt-[calc(6rem+1px)]" /> <div ref={topRef} className="scroll-mt-[calc(6rem+1px)]" />
{listMode === '24h' && !disable24hMode ? ( {listMode === '24h' && !disable24hMode ? (

View file

@ -14,13 +14,15 @@ export default function Tabs({
value, value,
onTabChange, onTabChange,
threshold = 800, threshold = 800,
options = null options = null,
active = false
}: { }: {
tabs: TabDefinition[] tabs: TabDefinition[]
value: string value: string
onTabChange?: (tab: string) => void onTabChange?: (tab: string) => void
threshold?: number threshold?: number
options?: ReactNode options?: ReactNode
active?: boolean
}) { }) {
const { t } = useTranslation() const { t } = useTranslation()
const { deepBrowsing, lastScrollTop } = useDeepBrowsing() const { deepBrowsing, lastScrollTop } = useDeepBrowsing()
@ -88,7 +90,9 @@ export default function Tabs({
ref={containerRef} ref={containerRef}
className={cn( className={cn(
'sticky flex justify-between top-12 bg-background z-30 px-1 w-full transition-all duration-300 border-b', 'sticky flex justify-between top-12 bg-background z-30 px-1 w-full transition-all duration-300 border-b',
deepBrowsing && lastScrollTop > threshold ? '-translate-y-[calc(100%+12rem)]' : '' deepBrowsing && lastScrollTop > threshold && !active
? '-translate-y-[calc(100%+12rem)]'
: ''
)} )}
> >
<ScrollArea className="flex-1 w-0"> <ScrollArea className="flex-1 w-0">

View file

@ -27,7 +27,11 @@ function getDescription(score: number, t: (key: string, options?: any) => string
} }
} }
export default function TrustScoreFilter() { export default function TrustScoreFilter({
onOpenChange
}: {
onOpenChange?: (open: boolean) => void
}) {
const { t } = useTranslation() const { t } = useTranslation()
const { isSmallScreen } = useScreenSize() const { isSmallScreen } = useScreenSize()
const { minTrustScore, updateMinTrustScore } = useUserTrust() const { minTrustScore, updateMinTrustScore } = useUserTrust()
@ -63,6 +67,12 @@ export default function TrustScoreFilter() {
} }
}, []) }, [])
useEffect(() => {
if (onOpenChange) {
onOpenChange(open)
}
}, [open, onOpenChange])
const description = getDescription(temporaryScore, t) const description = getDescription(temporaryScore, t)
const trigger = ( const trigger = (
@ -76,9 +86,7 @@ export default function TrustScoreFilter() {
: 'text-primary hover:text-primary-hover' : 'text-primary hover:text-primary-hover'
)} )}
onClick={() => { onClick={() => {
if (isSmallScreen) { setOpen(true)
setOpen(true)
}
}} }}
> >
{minTrustScore < 100 ? <Shield size={16} /> : <ShieldCheck size={16} />} {minTrustScore < 100 ? <Shield size={16} /> : <ShieldCheck size={16} />}