Wire up background message migration

pull/1/head
Daniel Gasienica 7 years ago
parent 4651cbc2eb
commit 5c9f18e1ae

@ -76,10 +76,26 @@
storage.fetch();
const idleListener = new IdleDetector();
idleListener.on('idle', (event) => {
console.log('Detected user idle:', event);
/* eslint-enable */
/* jshint ignore:start */
const idleDetector = new IdleDetector();
idleDetector.on('idle', async () => {
const results = await MessageMigration.processNext({
BackboneMessage: Whisper.Message,
BackboneMessageCollection: Whisper.MessageCollection,
count: 3,
upgradeMessageSchema,
wrapDeferred,
});
console.log('Message schema upgrade:', results);
if (!results.hasMore) {
idleDetector.stop();
}
});
/* jshint ignore:end */
/* eslint-disable */
// We need this 'first' check because we don't want to start the app up any other time
// than the first time. And storage.fetch() will cause onready() to fire.
@ -91,11 +107,11 @@
first = false;
ConversationController.load().then(start, start);
idleListener.start();
idleDetector.start();
});
Whisper.events.on('shutdown', function() {
idleListener.stop();
idleDetector.stop();
if (messageReceiver) {
messageReceiver.close().then(function() {

@ -122,12 +122,12 @@
const upgradeMessageSchema = message =>
Message.upgradeSchema(message, upgradeSchemaContext);
window.Signal = window.Signal || {};
const { IdleDetector} = require('./js/modules/idle_detector');
window.Signal.IdleDetector = IdleDetector;
window.Signal = window.Signal || {};
window.Signal.IdleDetector = IdleDetector;
window.Signal.Logs = require('./js/modules/logs');
window.Signal.MessageMigration = require('./js/modules/messages_migration');
window.Signal.OS = require('./js/modules/os');
window.Signal.Backup = require('./js/modules/backup');
window.Signal.Crypto = require('./js/modules/crypto');

Loading…
Cancel
Save