Skip to content

Commit d5cb3f5

Browse files
committed
refactor(web): initial-ripple-check
1 parent 4a4b27e commit d5cb3f5

File tree

1 file changed

+14
-6
lines changed
  • web/src/pages/Cases/CaseDetails/MaintenanceButtons

1 file changed

+14
-6
lines changed

web/src/pages/Cases/CaseDetails/MaintenanceButtons/index.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,9 @@ const MaintenanceButtons: React.FC = () => {
6161
// using interval here instead of useMemo with dispute, since we can't tell when period has timed out,
6262
// we can use useCountdown, but that would trigger the update every 1 sec. so this is ideal.
6363
useEffect(() => {
64-
const intervalId = setInterval(() => {
64+
const rippleCheck = () => {
6565
if (!dispute) return;
6666

67-
if (dispute.ruled) {
68-
clearInterval(intervalId);
69-
return;
70-
}
71-
7267
const period = Periods[dispute?.period] ?? 0;
7368
const now = Date.now() / 1000;
7469

@@ -82,6 +77,19 @@ const MaintenanceButtons: React.FC = () => {
8277
}
8378

8479
setDisplayRipple(false);
80+
};
81+
82+
// initial check
83+
rippleCheck();
84+
85+
const intervalId = setInterval(() => {
86+
if (!dispute) return;
87+
88+
if (dispute.ruled) {
89+
clearInterval(intervalId);
90+
return;
91+
}
92+
rippleCheck();
8593
}, 5000);
8694

8795
return () => clearInterval(intervalId);

0 commit comments

Comments
 (0)