Improve cold start performance

This commit is contained in:
Josh Perez 2021-03-04 16:44:57 -05:00 committed by Josh Perez
parent c73e35b1b6
commit d82ce07942
39 changed files with 911 additions and 628 deletions

View 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);