Remove legacy import flow

This commit is contained in:
Scott Nonnenberg 2020-03-03 18:47:01 -08:00
parent 2105b5341a
commit a840e2e5b1
15 changed files with 20 additions and 559 deletions

View file

@ -139,10 +139,6 @@
"message": "Toggle Developer Tools",
"description": "View menu command to show or hide the developer tools"
},
"menuSetupWithImport": {
"message": "Set Up with Import",
"description": "When the application is not yet set up, menu option to start up the import sequence"
},
"menuSetupAsNewDevice": {
"message": "Set Up as New Device",
"description": "When the application is not yet set up, menu option to start up the set up as fresh device"

View file

@ -14,7 +14,6 @@ exports.createTemplate = (options, messages) => {
platform,
setupAsNewDevice,
setupAsStandalone,
setupWithImport,
showAbout,
showDebugLog,
showKeyboardShortcuts,
@ -190,10 +189,6 @@ exports.createTemplate = (options, messages) => {
label: messages.menuSetupAsNewDevice.message,
click: setupAsNewDevice,
});
fileMenu.submenu.unshift({
label: messages.menuSetupWithImport.message,
click: setupWithImport,
});
}
if (platform === 'darwin') {

View file

@ -219,82 +219,6 @@
{{/isStep2}}
</script>
<script type='text/x-tmpl-mustache' id='import-flow-template'>
{{#isStep2}}
<div id='step2' class='step'>
<div class='inner'>
<div class='step-body'>
<span class='banner-icon folder-outline'></span>
<div class='header'>{{ chooseHeader }}</div>
<div class='body-text'>{{ choose }}</div>
</div>
<div class='nav'>
<div>
<a class='button choose'>{{ chooseButton }}</a>
</div>
</div>
</div>
</div>
{{/isStep2}}
{{#isStep3}}
<div id='step3' class='step'>
<div class='inner'>
<div class='step-body'>
<span class='banner-icon import'></span>
<div class='header'>{{ importingHeader }}</div>
</div>
<div class='progress'>
<div class='bar-container'>
<div class='bar progress-bar progress-bar-striped active'></div>
</div>
</div>
</div>
</div>
{{/isStep3}}
{{#isStep4}}
<div id='step4' class='step'>
<div class='inner'>
<div class='step-body'>
<span class='banner-icon check-circle-outline'></span>
<div class='header'>{{ completeHeader }}</div>
</div>
<div class='nav'>
{{#restartButton}}
<div>
<a class='button restart'>{{ restartButton }}</a>
</div>
{{/restartButton}}
{{#registerButton}}
<div>
<a class='button register'>{{ registerButton }}</a>
</div>
{{/registerButton}}
</div>
</div>
</div>
{{/isStep4}}
{{#isError}}
<div id='error' class='step'>
<div class='inner error-dialog clearfix'>
<div class='step-body'>
<span class='banner-icon alert-outline'></span>
<div class='header'>{{ errorHeader }}</div>
<div class='body-text-wide'>
{{ errorMessageFirst }}
<p>{{ errorMessageSecond }}</p>
</div>
</div>
<div class='nav'>
<div>
<a class='button choose'>{{ chooseButton }}</a>
</div>
</div>
</div>
</div>
{{/isError}}
</script>
<script type='text/x-tmpl-mustache' id='link-flow-template'>
{{#isStep3}}
<div id='step3' class='step'>
@ -459,7 +383,6 @@
<script type="text/javascript" src="js/views/phone-input-view.js"></script>
<script type='text/javascript' src='js/views/standalone_registration_view.js'></script>
<script type='text/javascript' src='js/views/app_view.js'></script>
<script type='text/javascript' src='js/views/import_view.js'></script>
<script type='text/javascript' src='js/views/clear_data_view.js'></script>
<script type='text/javascript' src='js/wall_clock_listener.js'></script>

View file

@ -382,10 +382,7 @@
showStickerPack: async (packId, key) => {
// We can get these events even if the user has never linked this instance.
if (
Whisper.Import.isIncomplete() ||
!window.Signal.Util.Registration.everDone()
) {
if (!window.Signal.Util.Registration.everDone()) {
return;
}
@ -1287,13 +1284,6 @@
});
}
Whisper.events.on('setupWithImport', () => {
const { appView } = window.owsDesktopApp;
if (appView) {
appView.openImporter();
}
});
Whisper.events.on('setupAsNewDevice', () => {
const { appView } = window.owsDesktopApp;
if (appView) {
@ -1382,10 +1372,7 @@
Whisper.ExpiringMessagesListener.init(Whisper.events);
Whisper.TapToViewMessagesListener.init(Whisper.events);
if (Whisper.Import.isIncomplete()) {
window.log.info('Import was interrupted, showing import error screen');
appView.openImporter();
} else if (window.Signal.Util.Registration.everDone()) {
if (window.Signal.Util.Registration.everDone()) {
// listeners
Whisper.RotateSignedPreKeyListener.init(Whisper.events, newVersion);
window.Signal.RefreshSenderCertificate.initialize({
@ -1399,8 +1386,6 @@
appView.openInbox({
initialLoadComplete,
});
} else if (window.isImportMode()) {
appView.openImporter();
} else {
appView.openInstaller();
}
@ -1513,9 +1498,6 @@
if (!window.Signal.Util.Registration.everDone()) {
return;
}
if (Whisper.Import.isIncomplete()) {
return;
}
if (messageReceiver) {
await messageReceiver.stopProcessing();
@ -1685,17 +1667,6 @@
);
});
}
if (Whisper.Import.isComplete()) {
wrap(
textsecure.messaging.sendRequestConfigurationSyncMessage(sendOptions)
).catch(error => {
window.log.error(
'Import complete, but failed to send sync message',
error && error.stack ? error.stack : error
);
});
}
}
storage.onready(async () => {

View file

@ -866,25 +866,25 @@ async function exportConversations(options) {
window.log.info('Done exporting conversations!');
}
function getDirectory(options = {}) {
return new Promise((resolve, reject) => {
const browserWindow = BrowserWindow.getFocusedWindow();
const dialogOptions = {
title: options.title,
properties: ['openDirectory'],
buttonLabel: options.buttonLabel,
};
async function getDirectory(options = {}) {
const browserWindow = BrowserWindow.getFocusedWindow();
const dialogOptions = {
title: options.title,
properties: ['openDirectory'],
buttonLabel: options.buttonLabel,
};
dialog.showOpenDialog(browserWindow, dialogOptions, directory => {
if (!directory || !directory[0]) {
const error = new Error('Error choosing directory');
error.name = 'ChooseError';
return reject(error);
}
const { canceled, filePaths } = await dialog.showOpenDialog(
browserWindow,
dialogOptions
);
if (canceled || !filePaths || !filePaths[0]) {
const error = new Error('Error choosing directory');
error.name = 'ChooseError';
throw error;
}
return resolve(directory[0]);
});
});
return filePaths[0];
}
function getDirContents(dir) {

View file

@ -66,40 +66,8 @@
this.debugLogView = null;
}
},
openImporter() {
window.addSetupMenuItems();
this.resetViews();
const importView = new Whisper.ImportView();
this.importView = importView;
this.listenTo(
importView,
'light-import',
this.finishLightImport.bind(this)
);
this.openView(this.importView);
},
finishLightImport() {
const options = {
hasExistingData: true,
};
this.openInstaller(options);
},
closeImporter() {
if (this.importView) {
this.importView.remove();
this.importView = null;
}
},
openInstaller(options = {}) {
// If we're in the middle of import, we don't want to show the menu options
// allowing the user to switch to other ways to set up the app. If they
// switched back and forth in the middle of a light import, they'd lose all
// that imported data.
if (!options.hasExistingData) {
window.addSetupMenuItems();
}
window.addSetupMenuItems();
this.resetViews();
const installView = new Whisper.InstallView(options);
@ -129,7 +97,6 @@
},
resetViews() {
this.closeInstaller();
this.closeImporter();
this.closeStandalone();
},
openInbox(options = {}) {

View file

@ -1,212 +0,0 @@
/* global Whisper, storage, i18n, ConversationController */
/* eslint-disable more/no-then */
// eslint-disable-next-line func-names
(function() {
'use strict';
window.Whisper = window.Whisper || {};
const State = {
IMPORTING: 1,
COMPLETE: 2,
LIGHT_COMPLETE: 3,
};
const IMPORT_STARTED = 'importStarted';
const IMPORT_COMPLETE = 'importComplete';
const IMPORT_LOCATION = 'importLocation';
Whisper.Import = {
isStarted() {
return Boolean(storage.get(IMPORT_STARTED));
},
isComplete() {
return Boolean(storage.get(IMPORT_COMPLETE));
},
isIncomplete() {
return this.isStarted() && !this.isComplete();
},
start() {
return storage.put(IMPORT_STARTED, true);
},
complete() {
return storage.put(IMPORT_COMPLETE, true);
},
saveLocation(location) {
return storage.put(IMPORT_LOCATION, location);
},
reset() {
return window.Signal.Data.removeAll();
},
};
Whisper.ImportView = Whisper.View.extend({
templateName: 'import-flow-template',
className: 'full-screen-flow',
events: {
'click .choose': 'onImport',
'click .restart': 'onRestart',
'click .cancel': 'onCancel',
'click .register': 'onRegister',
},
initialize() {
if (Whisper.Import.isIncomplete()) {
this.error = true;
}
this.render();
this.pending = Promise.resolve();
},
render_attributes() {
if (this.error) {
return {
isError: true,
errorHeader: i18n('importErrorHeader'),
errorMessageFirst: i18n('importErrorFirst'),
errorMessageSecond: i18n('importErrorSecond'),
chooseButton: i18n('importAgain'),
};
}
let restartButton = i18n('importCompleteStartButton');
let registerButton = i18n('importCompleteLinkButton');
let step = 'step2';
if (this.state === State.IMPORTING) {
step = 'step3';
} else if (this.state === State.COMPLETE) {
registerButton = null;
step = 'step4';
} else if (this.state === State.LIGHT_COMPLETE) {
restartButton = null;
step = 'step4';
}
return {
isStep2: step === 'step2',
chooseHeader: i18n('loadDataHeader'),
choose: i18n('loadDataDescription'),
chooseButton: i18n('chooseDirectory'),
isStep3: step === 'step3',
importingHeader: i18n('importingHeader'),
isStep4: step === 'step4',
completeHeader: i18n('importCompleteHeader'),
restartButton,
registerButton,
};
},
onRestart() {
return window.restart();
},
onCancel() {
this.trigger('cancel');
},
onImport() {
window.Signal.Backup.getDirectoryForImport().then(
directory => {
this.doImport(directory);
},
error => {
if (error.name !== 'ChooseError') {
window.log.error(
'Error choosing directory:',
error && error.stack ? error.stack : error
);
}
}
);
},
onRegister() {
// AppView listens for this, and opens up InstallView to the QR code step to
// finish setting this device up.
this.trigger('light-import');
},
doImport(directory) {
window.removeSetupMenuItems();
this.error = null;
this.state = State.IMPORTING;
this.render();
// Wait for prior database interaction to complete
this.pending = this.pending
.then(() =>
// For resilience to interruption, clear database both before and on failure
Whisper.Import.reset()
)
.then(() =>
Promise.all([
Whisper.Import.start(),
window.Signal.Backup.importFromDirectory(directory),
])
)
.then(results => {
const importResult = results[1];
// 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);
})
.catch(error => {
window.log.error(
'Error importing:',
error && error.stack ? error.stack : error
);
this.error = error || new Error('Something went wrong!');
this.state = null;
this.render();
return Whisper.Import.reset();
});
},
finishLightImport(directory) {
ConversationController.reset();
return ConversationController.load()
.then(() =>
Promise.all([
Whisper.Import.saveLocation(directory),
Whisper.Import.complete(),
])
)
.then(() => {
this.state = State.LIGHT_COMPLETE;
this.render();
});
},
finishFullImport(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()
.then(() =>
Promise.all([
// Clearing any migration-related state inherited from the Chrome App
storage.remove('migrationState'),
storage.remove('migrationEnabled'),
storage.remove('migrationEverCompleted'),
storage.remove('migrationStorageLocation'),
Whisper.Import.saveLocation(directory),
Whisper.Import.complete(),
])
)
.then(() => {
this.state = State.COMPLETE;
this.render();
});
},
});
})();

View file

@ -468,12 +468,6 @@ function showKeyboardShortcuts() {
}
}
function setupWithImport() {
if (mainWindow) {
mainWindow.webContents.send('set-up-with-import');
}
}
function setupAsNewDevice() {
if (mainWindow) {
mainWindow.webContents.send('set-up-as-new-device');
@ -890,7 +884,6 @@ function setupMenu(options) {
openSupportPage,
openForums,
platform,
setupWithImport,
setupAsNewDevice,
setupAsStandalone,
};

View file

@ -30,7 +30,6 @@ try {
window.getEnvironment = () => config.environment;
window.getAppInstance = () => config.appInstance;
window.getVersion = () => config.version;
window.isImportMode = () => config.importMode;
window.getExpiration = () => config.buildExpiration;
window.getNodeVersion = () => config.node_version;
window.getHostName = () => config.hostname;
@ -106,10 +105,6 @@ try {
window.updateTrayIcon = unreadCount =>
ipc.send('update-tray-icon', unreadCount);
ipc.on('set-up-with-import', () => {
Whisper.events.trigger('setupWithImport');
});
ipc.on('set-up-as-new-device', () => {
Whisper.events.trigger('setupAsNewDevice');
});

View file

@ -1,74 +0,0 @@
/* eslint-disable no-console */
const fs = require('fs');
const _ = require('lodash');
const packageJson = require('./package.json');
const defaultConfig = require('./config/default.json');
function checkValue(object, objectPath, expected) {
const actual = _.get(object, objectPath);
if (actual !== expected) {
throw new Error(`${objectPath} was ${actual}; expected ${expected}`);
}
}
// You might be wondering why this file is necessary. We have some very specific
// requirements around our import-flavor builds. They need to look exactly the same as
// normal builds, but they must immediately open into import mode. So they need a
// slight config tweak, and then a change to the .app/.exe name (note: we do NOT want to
// change where data is stored or anything, since that would make these builds
// incompatible with the mainline builds) So we just change the artifact name.
//
// Another key thing to know about these builds is that we should not upload the
// latest.yml (windows) and latest-mac.yml (mac) that go along with the executables.
// This would interrupt the normal install flow for users installing from
// signal.org/download. So any release script will need to upload these files manually
// instead of relying on electron-builder, which will upload everything.
// -------
console.log('prepare_import_build: updating config/default.json');
const IMPORT_PATH = 'import';
const IMPORT_START_VALUE = false;
const IMPORT_END_VALUE = true;
checkValue(defaultConfig, IMPORT_PATH, IMPORT_START_VALUE);
_.set(defaultConfig, IMPORT_PATH, IMPORT_END_VALUE);
// -------
console.log('prepare_import_build: updating package.json');
const MAC_ASSET_PATH = 'build.mac.artifactName';
// eslint-disable-next-line no-template-curly-in-string
const MAC_ASSET_START_VALUE = '${name}-mac-${version}.${ext}';
// eslint-disable-next-line no-template-curly-in-string
const MAC_ASSET_END_VALUE = '${name}-mac-${version}-import.${ext}';
const WIN_ASSET_PATH = 'build.win.artifactName';
// eslint-disable-next-line no-template-curly-in-string
const WIN_ASSET_START_VALUE = '${name}-win-${version}.${ext}';
// eslint-disable-next-line no-template-curly-in-string
const WIN_ASSET_END_VALUE = '${name}-win-${version}-import.${ext}';
checkValue(packageJson, MAC_ASSET_PATH, MAC_ASSET_START_VALUE);
checkValue(packageJson, WIN_ASSET_PATH, WIN_ASSET_START_VALUE);
_.set(packageJson, MAC_ASSET_PATH, MAC_ASSET_END_VALUE);
_.set(packageJson, WIN_ASSET_PATH, WIN_ASSET_END_VALUE);
const MAC_BUILD_TARGET = 'build.mac.target';
const MAC_BUILD_TARGET_END_VALUE = ['dmg'];
_.set(packageJson, MAC_BUILD_TARGET, MAC_BUILD_TARGET_END_VALUE);
// ---
fs.writeFileSync(
'./config/default.json',
JSON.stringify(defaultConfig, null, ' ')
);
fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, ' '));

View file

@ -41,10 +41,6 @@
{
"label": "&File",
"submenu": [
{
"label": "Set Up with Import",
"click": null
},
{
"label": "Set Up as New Device",
"click": null

View file

@ -2,10 +2,6 @@
{
"label": "&File",
"submenu": [
{
"label": "Set Up with Import",
"click": null
},
{
"label": "Set Up as New Device",
"click": null

View file

@ -54,7 +54,6 @@ describe('SignalMenu', () => {
includeSetup,
setupAsNewDevice: null,
setupAsStandalone: null,
setupWithImport: null,
showAbout: null,
showDebugLog: null,
showKeyboardShortcuts: null,

View file

@ -229,82 +229,6 @@
{{/isStep2}}
</script>
<script type='text/x-tmpl-mustache' id='import-flow-template'>
{{#isStep2}}
<div id='step2' class='step'>
<div class='inner'>
<div class='step-body'>
<span class='banner-icon folder-outline'></span>
<div class='header'>{{ chooseHeader }}</div>
<div class='body-text'>{{ choose }}</div>
</div>
<div class='nav'>
<div>
<a class='button choose'>{{ chooseButton }}</a>
</div>
</div>
</div>
</div>
{{/isStep2}}
{{#isStep3}}
<div id='step3' class='step'>
<div class='inner'>
<div class='step-body'>
<span class='banner-icon import'></span>
<div class='header'>{{ importingHeader }}</div>
</div>
<div class='progress'>
<div class='bar-container'>
<div class='bar progress-bar progress-bar-striped active'></div>
</div>
</div>
</div>
</div>
{{/isStep3}}
{{#isStep4}}
<div id='step4' class='step'>
<div class='inner'>
<div class='step-body'>
<span class='banner-icon check-circle-outline'></span>
<div class='header'>{{ completeHeader }}</div>
</div>
<div class='nav'>
{{#restartButton}}
<div>
<a class='button restart'>{{ restartButton }}</a>
</div>
{{/restartButton}}
{{#registerButton}}
<div>
<a class='button register'>{{ registerButton }}</a>
</div>
{{/registerButton}}
</div>
</div>
</div>
{{/isStep4}}
{{#isError}}
<div id='error' class='step'>
<div class='inner error-dialog clearfix'>
<div class='step-body'>
<span class='banner-icon alert-outline'></span>
<div class='header'>{{ errorHeader }}</div>
<div class='body-text-wide'>
{{ errorMessageFirst }}
<p>{{ errorMessageSecond }}</p>
</div>
</div>
<div class='nav'>
<div>
<a class='button choose'>{{ chooseButton }}</a>
</div>
</div>
</div>
</div>
{{/isError}}
</script>
<script type='text/x-tmpl-mustache' id='link-flow-template'>
{{#isStep3}}
<div id='step3' class='step'>

View file

@ -449,14 +449,6 @@
"updated": "2018-09-15T00:38:04.183Z",
"reasonDetail": "Getting the value, not setting it"
},
{
"rule": "jQuery-load(",
"path": "js/views/import_view.js",
"line": " return ConversationController.load()",
"lineNumber": 176,
"reasonCategory": "falseMatch",
"updated": "2018-09-15T00:38:04.183Z"
},
{
"rule": "jQuery-appendTo(",
"path": "js/views/inbox_view.js",