Improve cold start performance
This commit is contained in:
parent
c73e35b1b6
commit
d82ce07942
39 changed files with 911 additions and 628 deletions
23
ts/util/incrementMessageCounter.ts
Normal file
23
ts/util/incrementMessageCounter.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { debounce } from 'lodash';
|
||||
|
||||
export function incrementMessageCounter(): number {
|
||||
if (!window.receivedAtCounter) {
|
||||
window.receivedAtCounter =
|
||||
Number(localStorage.getItem('lastReceivedAtCounter')) || Date.now();
|
||||
}
|
||||
|
||||
window.receivedAtCounter += 1;
|
||||
debouncedUpdateLastReceivedAt();
|
||||
|
||||
return window.receivedAtCounter;
|
||||
}
|
||||
|
||||
const debouncedUpdateLastReceivedAt = debounce(() => {
|
||||
localStorage.setItem(
|
||||
'lastReceivedAtCounter',
|
||||
String(window.receivedAtCounter)
|
||||
);
|
||||
}, 500);
|
Loading…
Add table
Add a link
Reference in a new issue