From aaf4d898357b115043a8b66005af0a0b1522b138 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Fri, 27 Mar 2026 16:42:05 +0100 Subject: [PATCH] clear strikes on empty relay pool --- src/components/NoteList/index.tsx | 19 +++++- src/components/RefreshButton/index.tsx | 32 ++++++++- src/hooks/use-long-press-action.ts | 54 +++++++++++++++ src/i18n/locales/en.ts | 1 + src/main.tsx | 2 + src/services/client.service.ts | 49 +++++++++++--- src/services/session-feed-snapshot.service.ts | 67 +++++++++++++++++++ 7 files changed, 214 insertions(+), 10 deletions(-) create mode 100644 src/hooks/use-long-press-action.ts diff --git a/src/components/NoteList/index.tsx b/src/components/NoteList/index.tsx index 5057f2f3..47f82591 100644 --- a/src/components/NoteList/index.tsx +++ b/src/components/NoteList/index.tsx @@ -26,6 +26,7 @@ import { useZap } from '@/providers/ZapProvider' import client from '@/services/client.service' import { getSessionFeedSnapshot, + hardReloadPreservingFeedSnapshots, setSessionFeedSnapshot } from '@/services/session-feed-snapshot.service' import type { TFeedSubRequest, TSubRequestFilter } from '@/types' @@ -48,6 +49,7 @@ import { useState } from 'react' import { CircleAlert } from 'lucide-react' +import { useLongPressAction } from '@/hooks/use-long-press-action' import { useTranslation } from 'react-i18next' import PullToRefresh from 'react-simple-pull-to-refresh' import { toast } from 'sonner' @@ -655,6 +657,8 @@ const NoteList = forwardRef( }, 500) }, [scrollToTop]) + const emptyFeedHardReloadLongPress = useLongPressAction(hardReloadPreservingFeedSnapshots) + useImperativeHandle(ref, () => ({ scrollToTop, refresh }), [scrollToTop, refresh]) useEffect(() => { @@ -1707,7 +1711,20 @@ const NoteList = forwardRef( role="status" >

{t('No posts loaded for this feed. Try refreshing.')}

- diff --git a/src/components/RefreshButton/index.tsx b/src/components/RefreshButton/index.tsx index f65de2b9..57d84c0b 100644 --- a/src/components/RefreshButton/index.tsx +++ b/src/components/RefreshButton/index.tsx @@ -1,17 +1,47 @@ import { Button } from '@/components/ui/button' import { Skeleton } from '@/components/ui/skeleton' +import { useLongPressAction } from '@/hooks/use-long-press-action' +import { hardReloadPreservingFeedSnapshots } from '@/services/session-feed-snapshot.service' import { RefreshCcw } from 'lucide-react' import { useState } from 'react' +import { useTranslation } from 'react-i18next' -export function RefreshButton({ onClick }: { onClick: () => void }) { +export function RefreshButton({ + onClick, + /** + * Long-press (~650ms). Default: full page reload while restoring session feed snapshots. + * Pass `null` to disable long-press hard reload. + */ + onLongPress +}: { + onClick: () => void + onLongPress?: (() => void) | null +}) { + const { t } = useTranslation() const [refreshing, setRefreshing] = useState(false) + const longPressEnabled = onLongPress !== null + const longPressFn = onLongPress === null ? () => {} : (onLongPress ?? hardReloadPreservingFeedSnapshots) + const { onPointerDown, onPointerUp, onPointerLeave, onPointerCancel, consumeIfLongPress } = + useLongPressAction(longPressFn, { enabled: longPressEnabled }) + + const longPressTitle = onLongPress === null ? undefined : t('refresh.longPressHardReload') return (