Add timestamp utilities with helpful names
This commit is contained in:
parent
9fa3359477
commit
a75402d290
8 changed files with 71 additions and 17 deletions
|
@ -1,6 +1,8 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { isMoreRecentThan } from './timestamp';
|
||||
|
||||
const SIX_HOURS = 1000 * 60 * 60 * 6;
|
||||
|
||||
export function isConversationUnregistered({
|
||||
|
@ -8,6 +10,6 @@ export function isConversationUnregistered({
|
|||
}: Readonly<{ discoveredUnregisteredAt?: number }>): boolean {
|
||||
return Boolean(
|
||||
discoveredUnregisteredAt &&
|
||||
discoveredUnregisteredAt > Date.now() - SIX_HOURS
|
||||
isMoreRecentThan(discoveredUnregisteredAt, SIX_HOURS)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -14026,7 +14026,7 @@
|
|||
"rule": "jQuery-load(",
|
||||
"path": "ts/LibSignalStore.js",
|
||||
"line": " await window.ConversationController.load();",
|
||||
"lineNumber": 810,
|
||||
"lineNumber": 811,
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-02-27T00:48:49.313Z"
|
||||
},
|
||||
|
@ -14034,7 +14034,7 @@
|
|||
"rule": "jQuery-load(",
|
||||
"path": "ts/LibSignalStore.ts",
|
||||
"line": " await window.ConversationController.load();",
|
||||
"lineNumber": 1221,
|
||||
"lineNumber": 1222,
|
||||
"reasonCategory": "falseMatch",
|
||||
"updated": "2021-02-27T00:48:49.313Z"
|
||||
},
|
||||
|
|
10
ts/util/timestamp.ts
Normal file
10
ts/util/timestamp.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
export function isMoreRecentThan(timestamp: number, delta: number): boolean {
|
||||
return timestamp > Date.now() - delta;
|
||||
}
|
||||
|
||||
export function isOlderThan(timestamp: number, delta: number): boolean {
|
||||
return timestamp <= Date.now() - delta;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue