diff --git a/js/views/migration_view.js b/js/views/migration_view.js index 9993b9567..af885a5e3 100644 --- a/js/views/migration_view.js +++ b/js/views/migration_view.js @@ -142,11 +142,7 @@ this.render(); }, beginMigration: function() { - // tells MessageReceiver to disconnect and drain its queue, will fire - // 'shutdown-complete' event when that is done. - Whisper.Migration.init(); - - Whisper.events.on('shutdown-complete', function() { + Whisper.events.once('shutdown-complete', function() { Whisper.Migration.beginExport() .then(this.completeMigration.bind(this)) .catch(this.onError.bind(this)); @@ -155,6 +151,11 @@ this.render(); }.bind(this)); + // tells MessageReceiver to disconnect and drain its queue, will fire + // 'shutdown-complete' event when that is done. Might result in a synchronous + // event, so call it after we register our callback. + Whisper.Migration.init(); + // Rendering because we're now in the 'disconnected' state this.render(); },