mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-25 18:55:44 +03:00
Test show refresh button after a minute
This commit is contained in:
parent
79e87b7d89
commit
9b0889fe23
1 changed files with 32 additions and 0 deletions
|
@ -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={{
|
||||
|
|
Loading…
Reference in a new issue