mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-26 11:15:43 +03:00
Disable poll auto-refresh at point of expiry
This commit is contained in:
parent
1405296e67
commit
3b100ad30f
1 changed files with 20 additions and 18 deletions
|
@ -1279,24 +1279,26 @@ function Poll({
|
||||||
const expiresAtDate = !!expiresAt && new Date(expiresAt);
|
const expiresAtDate = !!expiresAt && new Date(expiresAt);
|
||||||
|
|
||||||
// Update poll at point of expiry
|
// Update poll at point of expiry
|
||||||
useEffect(() => {
|
// NOTE: Disable this because setTimeout runs immediately if delay is too large
|
||||||
let timeout;
|
// https://stackoverflow.com/a/56718027/20838
|
||||||
if (!expired && expiresAtDate) {
|
// useEffect(() => {
|
||||||
const ms = expiresAtDate.getTime() - Date.now() + 1; // +1 to give it a little buffer
|
// let timeout;
|
||||||
if (ms > 0) {
|
// if (!expired && expiresAtDate) {
|
||||||
timeout = setTimeout(() => {
|
// const ms = expiresAtDate.getTime() - Date.now() + 1; // +1 to give it a little buffer
|
||||||
setUIState('loading');
|
// if (ms > 0) {
|
||||||
(async () => {
|
// timeout = setTimeout(() => {
|
||||||
await refresh();
|
// setUIState('loading');
|
||||||
setUIState('default');
|
// (async () => {
|
||||||
})();
|
// // await refresh();
|
||||||
}, ms);
|
// setUIState('default');
|
||||||
}
|
// })();
|
||||||
}
|
// }, ms);
|
||||||
return () => {
|
// }
|
||||||
clearTimeout(timeout);
|
// }
|
||||||
};
|
// return () => {
|
||||||
}, [expired, expiresAtDate]);
|
// clearTimeout(timeout);
|
||||||
|
// };
|
||||||
|
// }, [expired, expiresAtDate]);
|
||||||
|
|
||||||
const pollVotesCount = votersCount || votesCount;
|
const pollVotesCount = votersCount || votesCount;
|
||||||
let roundPrecision = 0;
|
let roundPrecision = 0;
|
||||||
|
|
Loading…
Reference in a new issue