Test show refresh button after a minute

This commit is contained in:
Lim Chee Aun 2024-01-14 18:31:53 +08:00
parent 79e87b7d89
commit 9b0889fe23

View file

@ -245,6 +245,7 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
}, [id, uiState !== 'loading']);
const scrollOffsets = useRef();
const lastInitContextTS = useRef();
const initContext = ({ reloadHero } = {}) => {
console.debug('initContext', id);
setUIState('loading');
@ -432,12 +433,31 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
}
})();
lastInitContextTS.current = Date.now();
return () => {
clearTimeout(heroTimer);
};
};
useEffect(initContext, [id, masto]);
const [showRefresh, setShowRefresh] = useState(false);
useEffect(() => {
let interval = setInterval(() => {
const now = Date.now();
if (
lastInitContextTS.current &&
now - lastInitContextTS.current >= 60_000
) {
setShowRefresh(true);
}
}, 60_000); // 1 minute
return () => {
clearInterval(interval);
};
}, []);
useLayoutEffect(() => {
if (!statuses.length) return;
console.debug('STATUSES', statuses);
@ -1095,6 +1115,18 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
>
<Icon icon="layout4" size="l" />
</button>
{showRefresh && (
<button
type="button"
class="plain4"
onClick={() => {
states.reloadStatusPage++;
setShowRefresh(false);
}}
>
<Icon icon="refresh" size="l" />
</button>
)}
<Menu2
align="end"
portal={{