Truncate lastHeartbeat to day millis

This commit is contained in:
Fedor Indutny 2021-09-24 10:01:46 -07:00 committed by GitHub
parent 7adfd1a4e7
commit af66a5b265
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 5 deletions

View file

@ -28,7 +28,7 @@ import { filter } from './util/iterables';
import { isNotNil } from './util/isNotNil';
import { senderCertificateService } from './services/senderCertificate';
import { routineProfileRefresh } from './routineProfileRefresh';
import { isMoreRecentThan, isOlderThan } from './util/timestamp';
import { isMoreRecentThan, isOlderThan, toDayMillis } from './util/timestamp';
import { isValidReactionEmoji } from './reactions/isValidReactionEmoji';
import { ConversationModel } from './models/conversations';
import { getMessageById } from './messages/getMessageById';
@ -672,7 +672,7 @@ export async function startApp(): Promise<void> {
webFrame.setZoomFactor(window.Events.getZoomFactor());
// How long since we were last running?
const lastHeartbeat = window.storage.get('lastHeartbeat', 0);
const lastHeartbeat = toDayMillis(window.storage.get('lastHeartbeat', 0));
const previousLastStartup = window.storage.get('lastStartup');
await window.storage.put('lastStartup', Date.now());
@ -685,10 +685,10 @@ export async function startApp(): Promise<void> {
}
// Start heartbeat timer
window.storage.put('lastHeartbeat', Date.now());
window.storage.put('lastHeartbeat', toDayMillis(Date.now()));
const TWELVE_HOURS = 12 * 60 * 60 * 1000;
setInterval(
() => window.storage.put('lastHeartbeat', Date.now()),
() => window.storage.put('lastHeartbeat', toDayMillis(Date.now())),
TWELVE_HOURS
);