Skip to content

Commit

Permalink
Merge pull request #93 from cheeaun/main
Browse files Browse the repository at this point in the history
Update from main
  • Loading branch information
cheeaun committed Apr 3, 2023
2 parents 546e77d + 3b100ad commit 4e50f22
Showing 1 changed file with 32 additions and 31 deletions.
63 changes: 32 additions & 31 deletions src/components/status.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1030,19 +1030,18 @@ function Status({
onClick={replyStatus}
/>
</div>
{canBoost && (
<div class="action has-count">
<StatusButton
checked={reblogged}
title={['Boost', 'Unboost']}
alt={['Boost', 'Boosted']}
class="reblog-button"
icon="rocket"
count={reblogsCount}
onClick={boostStatus}
/>
</div>
)}
<div class="action has-count">
<StatusButton
checked={reblogged}
title={['Boost', 'Unboost']}
alt={['Boost', 'Boosted']}
class="reblog-button"
icon="rocket"
count={reblogsCount}
onClick={boostStatus}
disabled={!canBoost}
/>
</div>
<div class="action has-count">
<StatusButton
checked={favourited}
Expand Down Expand Up @@ -1280,24 +1279,26 @@ function Poll({
const expiresAtDate = !!expiresAt && new Date(expiresAt);

// Update poll at point of expiry
useEffect(() => {
let timeout;
if (!expired && expiresAtDate) {
const ms = expiresAtDate.getTime() - Date.now() + 1; // +1 to give it a little buffer
if (ms > 0) {
timeout = setTimeout(() => {
setUIState('loading');
(async () => {
await refresh();
setUIState('default');
})();
}, ms);
}
}
return () => {
clearTimeout(timeout);
};
}, [expired, expiresAtDate]);
// NOTE: Disable this because setTimeout runs immediately if delay is too large
// https://stackoverflow.com/a/56718027/20838
// useEffect(() => {
// let timeout;
// if (!expired && expiresAtDate) {
// const ms = expiresAtDate.getTime() - Date.now() + 1; // +1 to give it a little buffer
// if (ms > 0) {
// timeout = setTimeout(() => {
// setUIState('loading');
// (async () => {
// // await refresh();
// setUIState('default');
// })();
// }, ms);
// }
// }
// return () => {
// clearTimeout(timeout);
// };
// }, [expired, expiresAtDate]);

const pollVotesCount = votersCount || votesCount;
let roundPrecision = 0;
Expand Down

0 comments on commit 4e50f22

Please sign in to comment.