From a4548306e7d2c2b48c7814e7c837b24699e4b2b3 Mon Sep 17 00:00:00 2001 From: Gigi Date: Wed, 15 Oct 2025 09:37:03 +0200 Subject: [PATCH] fix(ui): update HighlightsPanel to use new pull-to-refresh library - Replace old usePullToRefresh hook with use-pull-to-refresh library - Update to use RefreshIndicator component - Remove ref-based implementation in favor of simpler library API --- src/components/HighlightsPanel.tsx | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/components/HighlightsPanel.tsx b/src/components/HighlightsPanel.tsx index b4687150..461de312 100644 --- a/src/components/HighlightsPanel.tsx +++ b/src/components/HighlightsPanel.tsx @@ -4,10 +4,10 @@ import { faHighlighter } from '@fortawesome/free-solid-svg-icons' import { Highlight } from '../types/highlights' import { HighlightItem } from './HighlightItem' import { useFilteredHighlights } from '../hooks/useFilteredHighlights' -import { usePullToRefresh } from '../hooks/usePullToRefresh' +import { usePullToRefresh } from 'use-pull-to-refresh' import HighlightsPanelCollapsed from './HighlightsPanel/HighlightsPanelCollapsed' import HighlightsPanelHeader from './HighlightsPanel/HighlightsPanelHeader' -import PullToRefreshIndicator from './PullToRefreshIndicator' +import RefreshIndicator from './RefreshIndicator' import { RelayPool } from 'applesauce-relay' import { IEventStore } from 'applesauce-core' import { UserSettings } from '../services/settingsService' @@ -60,7 +60,6 @@ export const HighlightsPanel: React.FC = ({ }) => { const [showHighlights, setShowHighlights] = useState(true) const [localHighlights, setLocalHighlights] = useState(highlights) - const highlightsListRef = useRef(null) const handleToggleHighlights = () => { const newValue = !showHighlights @@ -69,14 +68,15 @@ export const HighlightsPanel: React.FC = ({ } // Pull-to-refresh for highlights - const pullToRefreshState = usePullToRefresh(highlightsListRef, { + const { isRefreshing, pullPosition } = usePullToRefresh({ onRefresh: () => { if (onRefresh) { onRefresh() } }, - isRefreshing: loading, - disabled: !onRefresh + maximumPullLength: 240, + refreshThreshold: 80, + isDisabled: !onRefresh }) // Keep track of highlight updates @@ -144,15 +144,10 @@ export const HighlightsPanel: React.FC = ({

) : ( -
- + {filteredHighlights.map((highlight) => (