From 465c06c67121b461f1d048d1f62ed89e752c029d Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 20 Jun 2023 12:45:57 +0800 Subject: [PATCH] Fix serious bug: `any` doesn't persist in subsequent calls --- src/pages/hashtag.jsx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/pages/hashtag.jsx b/src/pages/hashtag.jsx index a7db6f1e..76337280 100644 --- a/src/pages/hashtag.jsx +++ b/src/pages/hashtag.jsx @@ -42,15 +42,25 @@ function Hashtags(props) { useTitle(title, `/:instance?/t/:hashtag`); const latestItem = useRef(); - const hashtagsIterator = useRef(); + // const hashtagsIterator = useRef(); + const maxID = useRef(undefined); async function fetchHashtags(firstLoad) { - if (firstLoad || !hashtagsIterator.current) { - hashtagsIterator.current = masto.v1.timelines.listHashtag(hashtag, { + // if (firstLoad || !hashtagsIterator.current) { + // hashtagsIterator.current = masto.v1.timelines.listHashtag(hashtag, { + // limit: LIMIT, + // any: hashtags.slice(1), + // }); + // } + // const results = await hashtagsIterator.current.next(); + + // NOTE: Temporary fix for listHashtag not persisting `any` in subsequent calls. + const results = await masto.v1.timelines + .listHashtag(hashtag, { limit: LIMIT, any: hashtags.slice(1), - }); - } - const results = await hashtagsIterator.current.next(); + maxId: firstLoad ? undefined : maxID.current, + }) + .next(); const { value } = results; if (value?.length) { if (firstLoad) { @@ -60,6 +70,8 @@ function Hashtags(props) { value.forEach((item) => { saveStatus(item, instance); }); + + maxID.current = value[value.length - 1].id; } return { ...results,