Visual indicator that it tries to get new updates

Probably too subtle. Loader also only appears after 1s delay 😆
This commit is contained in:
Lim Chee Aun 2022-12-21 08:54:39 +08:00
parent becb8aa89d
commit 237ceae356

View file

@ -82,6 +82,7 @@ function Home({ hidden }) {
const diffMins = Math.round(diff / 1000 / 60); const diffMins = Math.round(diff / 1000 / 60);
if (diffMins > 1) { if (diffMins > 1) {
console.log('visible', { lastHidden, diffMins }); console.log('visible', { lastHidden, diffMins });
setUIState('loading');
setTimeout(() => { setTimeout(() => {
(async () => { (async () => {
const newStatus = await masto.timelines.fetchHome({ const newStatus = await masto.timelines.fetchHome({
@ -91,6 +92,7 @@ function Home({ hidden }) {
if (newStatus.length && newStatus[0].id !== states.home[0].id) { if (newStatus.length && newStatus[0].id !== states.home[0].id) {
states.homeNew = newStatus; states.homeNew = newStatus;
} }
setUIState('default');
})(); })();
// loadStatuses(true); // loadStatuses(true);
// states.homeNew = []; // states.homeNew = [];
@ -101,6 +103,7 @@ function Home({ hidden }) {
document.addEventListener('visibilitychange', handleVisibilityChange); document.addEventListener('visibilitychange', handleVisibilityChange);
return () => { return () => {
document.removeEventListener('visibilitychange', handleVisibilityChange); document.removeEventListener('visibilitychange', handleVisibilityChange);
setUIState('default');
}; };
}, []); }, []);