mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-26 21:28:40 +00:00
Format all source code using Prettier
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* vim: ts=4:sw=4:expandtab
|
||||
*/
|
||||
(function () {
|
||||
(function() {
|
||||
'use strict';
|
||||
window.Whisper = window.Whisper || {};
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
},
|
||||
reset: function() {
|
||||
return Whisper.Database.clear();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Whisper.ImportView = Whisper.View.extend({
|
||||
@@ -102,16 +102,19 @@
|
||||
this.trigger('cancel');
|
||||
},
|
||||
onImport: function() {
|
||||
window.Signal.Backup.getDirectoryForImport().then(function(directory) {
|
||||
this.doImport(directory);
|
||||
}.bind(this), function(error) {
|
||||
if (error.name !== 'ChooseError') {
|
||||
console.log(
|
||||
'Error choosing directory:',
|
||||
error && error.stack ? error.stack : error
|
||||
);
|
||||
window.Signal.Backup.getDirectoryForImport().then(
|
||||
function(directory) {
|
||||
this.doImport(directory);
|
||||
}.bind(this),
|
||||
function(error) {
|
||||
if (error.name !== 'ChooseError') {
|
||||
console.log(
|
||||
'Error choosing directory:',
|
||||
error && error.stack ? error.stack : error
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
},
|
||||
onRegister: function() {
|
||||
// AppView listens for this, and opens up InstallView to the QR code step to
|
||||
@@ -127,53 +130,69 @@
|
||||
this.render();
|
||||
|
||||
// Wait for prior database interaction to complete
|
||||
this.pending = this.pending.then(function() {
|
||||
// For resilience to interruption, clear database both before and on failure
|
||||
return Whisper.Import.reset();
|
||||
}).then(function() {
|
||||
return Promise.all([
|
||||
Whisper.Import.start(),
|
||||
window.Signal.Backup.importFromDirectory(directory)
|
||||
]);
|
||||
}).then(function(results) {
|
||||
var importResult = results[1];
|
||||
this.pending = this.pending
|
||||
.then(function() {
|
||||
// For resilience to interruption, clear database both before and on failure
|
||||
return Whisper.Import.reset();
|
||||
})
|
||||
.then(function() {
|
||||
return Promise.all([
|
||||
Whisper.Import.start(),
|
||||
window.Signal.Backup.importFromDirectory(directory),
|
||||
]);
|
||||
})
|
||||
.then(
|
||||
function(results) {
|
||||
var importResult = results[1];
|
||||
|
||||
// A full import changes so much we need a restart of the app
|
||||
if (importResult.fullImport) {
|
||||
return this.finishFullImport(directory);
|
||||
}
|
||||
// A full import changes so much we need a restart of the app
|
||||
if (importResult.fullImport) {
|
||||
return this.finishFullImport(directory);
|
||||
}
|
||||
|
||||
// A light import just brings in contacts, groups, and messages. And we need a
|
||||
// normal link to finish the process.
|
||||
return this.finishLightImport(directory);
|
||||
}.bind(this)).catch(function(error) {
|
||||
console.log('Error importing:', error && error.stack ? error.stack : error);
|
||||
// A light import just brings in contacts, groups, and messages. And we need a
|
||||
// normal link to finish the process.
|
||||
return this.finishLightImport(directory);
|
||||
}.bind(this)
|
||||
)
|
||||
.catch(
|
||||
function(error) {
|
||||
console.log(
|
||||
'Error importing:',
|
||||
error && error.stack ? error.stack : error
|
||||
);
|
||||
|
||||
this.error = error || new Error('Something went wrong!');
|
||||
this.state = null;
|
||||
this.render();
|
||||
this.error = error || new Error('Something went wrong!');
|
||||
this.state = null;
|
||||
this.render();
|
||||
|
||||
return Whisper.Import.reset();
|
||||
}.bind(this));
|
||||
return Whisper.Import.reset();
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
finishLightImport: function(directory) {
|
||||
ConversationController.reset();
|
||||
|
||||
return ConversationController.load().then(function() {
|
||||
return Promise.all([
|
||||
return ConversationController.load()
|
||||
.then(function() {
|
||||
return Promise.all([
|
||||
Whisper.Import.saveLocation(directory),
|
||||
Whisper.Import.complete(),
|
||||
]);
|
||||
}).then(function() {
|
||||
this.state = State.LIGHT_COMPLETE;
|
||||
this.render();
|
||||
}.bind(this));
|
||||
})
|
||||
.then(
|
||||
function() {
|
||||
this.state = State.LIGHT_COMPLETE;
|
||||
this.render();
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
finishFullImport: function(directory) {
|
||||
// Catching in-memory cache up with what's in indexeddb now...
|
||||
// NOTE: this fires storage.onready, listened to across the app. We'll restart
|
||||
// to complete the install to start up cleanly with everything now in the DB.
|
||||
return storage.fetch()
|
||||
return storage
|
||||
.fetch()
|
||||
.then(function() {
|
||||
return Promise.all([
|
||||
// Clearing any migration-related state inherited from the Chrome App
|
||||
@@ -183,12 +202,15 @@
|
||||
storage.remove('migrationStorageLocation'),
|
||||
|
||||
Whisper.Import.saveLocation(directory),
|
||||
Whisper.Import.complete()
|
||||
Whisper.Import.complete(),
|
||||
]);
|
||||
}).then(function() {
|
||||
this.state = State.COMPLETE;
|
||||
this.render();
|
||||
}.bind(this));
|
||||
}
|
||||
})
|
||||
.then(
|
||||
function() {
|
||||
this.state = State.COMPLETE;
|
||||
this.render();
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user