Skip to content

Commit 32f0746

Browse files
authored
fix(time-offset): detect time in the past (#6011)
* fix(time-offset): detect also when local time is in the past * refactor: add return type and remove warning
1 parent 8ca838b commit 32f0746

File tree

1 file changed

+4
-4
lines changed
  • apps/cowswap-frontend/src/common/containers/InvalidLocalTimeWarning

1 file changed

+4
-4
lines changed

apps/cowswap-frontend/src/common/containers/InvalidLocalTimeWarning/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ReactNode } from 'react'
2+
13
import { useLocalTimeOffset } from './localTimeOffsetState'
24

35
import { GlobalWarning } from '../../pure/GlobalWarning'
@@ -7,12 +9,10 @@ const TIME_OFFSET_THRESHOLD = 60 // 60 seconds
79
/**
810
* When the local device time is not valid ()
911
*/
10-
// TODO: Add proper return type annotation
11-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
12-
export function InvalidLocalTimeWarning() {
12+
export function InvalidLocalTimeWarning(): ReactNode | null {
1313
const localTimeOffset = useLocalTimeOffset()
1414

15-
if (!localTimeOffset || localTimeOffset < TIME_OFFSET_THRESHOLD) return null
15+
if (!localTimeOffset || Math.abs(localTimeOffset) < TIME_OFFSET_THRESHOLD) return null
1616

1717
console.debug('Local time offset:', localTimeOffset)
1818

0 commit comments

Comments
 (0)