Do not initialize receivedAtCounter
in connect
This commit is contained in:
parent
d222376b8f
commit
6343e7c902
3 changed files with 7 additions and 12 deletions
|
@ -3,21 +3,20 @@
|
|||
|
||||
import { debounce } from 'lodash';
|
||||
|
||||
let receivedAtCounter: number | undefined;
|
||||
|
||||
export function incrementMessageCounter(): number {
|
||||
if (!window.receivedAtCounter) {
|
||||
window.receivedAtCounter =
|
||||
if (!receivedAtCounter) {
|
||||
receivedAtCounter =
|
||||
Number(localStorage.getItem('lastReceivedAtCounter')) || Date.now();
|
||||
}
|
||||
|
||||
window.receivedAtCounter += 1;
|
||||
receivedAtCounter += 1;
|
||||
debouncedUpdateLastReceivedAt();
|
||||
|
||||
return window.receivedAtCounter;
|
||||
return receivedAtCounter;
|
||||
}
|
||||
|
||||
const debouncedUpdateLastReceivedAt = debounce(() => {
|
||||
localStorage.setItem(
|
||||
'lastReceivedAtCounter',
|
||||
String(window.receivedAtCounter)
|
||||
);
|
||||
localStorage.setItem('lastReceivedAtCounter', String(receivedAtCounter));
|
||||
}, 500);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue