mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-09-27 20:17:05 +02:00
fix initial load issue
This commit is contained in:
@@ -46,18 +46,22 @@ function GenericNoteTimeline({ timeline }: { timeline: TimelineLoader }) {
|
|||||||
[cachedLocationKey, timeline],
|
[cachedLocationKey, timeline],
|
||||||
);
|
);
|
||||||
|
|
||||||
const [pinDate, setPinDate] = useState(getCachedNumber("pin") ?? events[NOTE_BUFFER]?.created_at ?? 0);
|
const [pinDate, setPinDate] = useState(getCachedNumber("pin") ?? events[NOTE_BUFFER]?.created_at ?? Infinity);
|
||||||
|
|
||||||
const [maxDate, setMaxDate] = useState(getCachedNumber("max") ?? Infinity);
|
const [maxDate, setMaxDate] = useState(getCachedNumber("max") ?? Infinity);
|
||||||
const [minDate, setMinDate] = useState(getCachedNumber("min") ?? events[NOTE_BUFFER]?.created_at ?? 0);
|
const [minDate, setMinDate] = useState(getCachedNumber("min") ?? events[NOTE_BUFFER]?.created_at ?? Infinity);
|
||||||
|
|
||||||
|
if (pinDate === Infinity && events.length > 0) setPinDate(events[NOTE_BUFFER]?.created_at);
|
||||||
|
if (minDate === Infinity && events.length > 0) setMinDate(events[NOTE_BUFFER]?.created_at);
|
||||||
|
|
||||||
// reset the latest and minDate when timeline changes
|
// reset the latest and minDate when timeline changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLatest(dayjs().unix());
|
setLatest(dayjs().unix());
|
||||||
|
setPinDate(getCachedNumber("pin") ?? timeline.timeline.value[NOTE_BUFFER]?.created_at ?? Infinity);
|
||||||
|
|
||||||
setMaxDate(getCachedNumber("max") ?? Infinity);
|
setMaxDate(getCachedNumber("max") ?? Infinity);
|
||||||
setPinDate(getCachedNumber("min") ?? timeline.timeline.value[NOTE_BUFFER]?.created_at ?? 0);
|
setMinDate(getCachedNumber("min") ?? timeline.timeline.value[NOTE_BUFFER]?.created_at ?? Infinity);
|
||||||
setPinDate(getCachedNumber("pin") ?? timeline.timeline.value[NOTE_BUFFER]?.created_at ?? 0);
|
}, [timeline, setPinDate, setMinDate, setMaxDate, setLatest, getCachedNumber]);
|
||||||
}, [timeline, setPinDate, setLatest, getCachedNumber]);
|
|
||||||
|
|
||||||
const updateNoteMinHeight = useCallback(
|
const updateNoteMinHeight = useCallback(
|
||||||
(id: string, element: Element) => {
|
(id: string, element: Element) => {
|
||||||
|
Reference in New Issue
Block a user