Rewrite WallClockListener as onTimeTravel

This commit is contained in:
Evan Hahn 2022-05-31 16:22:31 +00:00 committed by GitHub
parent 11cfb4f76f
commit 6668348197
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 82 additions and 30 deletions

View file

@ -1,28 +0,0 @@
// Copyright 2017-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
/* global Whisper */
// eslint-disable-next-line func-names
(function () {
window.Whisper = window.Whisper || {};
let lastTime;
const interval = 1000;
let events;
function checkTime() {
const currentTime = Date.now();
if (currentTime > lastTime + interval * 2) {
events.trigger('timetravel');
}
lastTime = currentTime;
}
Whisper.WallClockListener = {
init(_events) {
events = _events;
lastTime = Date.now();
setInterval(checkTime, interval);
},
};
})();