Do not initialize receivedAtCounter
in connect
This commit is contained in:
parent
d222376b8f
commit
6343e7c902
3 changed files with 7 additions and 12 deletions
|
@ -2173,9 +2173,6 @@ export async function startApp(): Promise<void> {
|
|||
let connectCount = 0;
|
||||
let connecting = false;
|
||||
async function connect(firstRun?: boolean) {
|
||||
window.receivedAtCounter =
|
||||
window.storage.get('lastReceivedAtCounter') || Date.now();
|
||||
|
||||
if (connecting) {
|
||||
window.log.warn('connect already running', { connectCount });
|
||||
return;
|
||||
|
|
|
@ -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);
|
||||
|
|
1
ts/window.d.ts
vendored
1
ts/window.d.ts
vendored
|
@ -189,7 +189,6 @@ declare global {
|
|||
baseAttachmentsPath: string;
|
||||
baseStickersPath: string;
|
||||
baseTempPath: string;
|
||||
receivedAtCounter: number;
|
||||
enterKeyboardMode: () => void;
|
||||
enterMouseMode: () => void;
|
||||
getAccountManager: () => AccountManager;
|
||||
|
|
Loading…
Reference in a new issue