Remove some global refs to window.events
// FREEBIE
This commit is contained in:
parent
510a5cb7fe
commit
fcff07df98
4 changed files with 12 additions and 10 deletions
|
@ -86,9 +86,9 @@
|
||||||
openInbox();
|
openInbox();
|
||||||
}
|
}
|
||||||
|
|
||||||
Whisper.WallClockListener.init();
|
Whisper.WallClockListener.init(events);
|
||||||
Whisper.RotateSignedPreKeyListener.init();
|
Whisper.RotateSignedPreKeyListener.init(events);
|
||||||
Whisper.ExpiringMessagesListener.init();
|
Whisper.ExpiringMessagesListener.init(events);
|
||||||
});
|
});
|
||||||
|
|
||||||
window.getSyncRequest = function() {
|
window.getSyncRequest = function() {
|
||||||
|
|
|
@ -37,9 +37,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Whisper.ExpiringMessagesListener = {
|
Whisper.ExpiringMessagesListener = {
|
||||||
init: function() {
|
init: function(events) {
|
||||||
checkExpiringMessages();
|
checkExpiringMessages();
|
||||||
window.events.on('timetravel', checkExpiringMessages);
|
events.on('timetravel', checkExpiringMessages);
|
||||||
},
|
},
|
||||||
update: checkExpiringMessages
|
update: checkExpiringMessages
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,15 +46,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Whisper.RotateSignedPreKeyListener = {
|
Whisper.RotateSignedPreKeyListener = {
|
||||||
init: function() {
|
init: function(events) {
|
||||||
if (Whisper.Registration.isDone()) {
|
if (Whisper.Registration.isDone()) {
|
||||||
setTimeoutForNextRun();
|
setTimeoutForNextRun();
|
||||||
}
|
}
|
||||||
window.events.on('registration_done', function() {
|
events.on('registration_done', function() {
|
||||||
scheduleNextRotation();
|
scheduleNextRotation();
|
||||||
setTimeoutForNextRun();
|
setTimeoutForNextRun();
|
||||||
});
|
});
|
||||||
window.events.on('timetravel', function() {
|
events.on('timetravel', function() {
|
||||||
if (Whisper.Registration.isDone()) {
|
if (Whisper.Registration.isDone()) {
|
||||||
setTimeoutForNextRun();
|
setTimeoutForNextRun();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,17 +8,19 @@
|
||||||
|
|
||||||
var lastTime;
|
var lastTime;
|
||||||
var interval = 1000;
|
var interval = 1000;
|
||||||
|
var events;
|
||||||
function checkTime() {
|
function checkTime() {
|
||||||
var currentTime = Date.now();
|
var currentTime = Date.now();
|
||||||
if (currentTime > (lastTime + interval * 2)) {
|
if (currentTime > (lastTime + interval * 2)) {
|
||||||
console.log('time travel detected!');
|
console.log('time travel detected!');
|
||||||
window.events.trigger('timetravel');
|
events.trigger('timetravel');
|
||||||
}
|
}
|
||||||
lastTime = currentTime;
|
lastTime = currentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
Whisper.WallClockListener = {
|
Whisper.WallClockListener = {
|
||||||
init: function() {
|
init: function(_events) {
|
||||||
|
events = _events;
|
||||||
lastTime = Date.now();
|
lastTime = Date.now();
|
||||||
setInterval(checkTime, 1000);
|
setInterval(checkTime, 1000);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue