Skip to content

Commit

Permalink
Merge pull request #10920 from vector-im/dbkr/fix_originmigrator_elec…
Browse files Browse the repository at this point in the history
…tron6_2

Fix origin migrator for SSO logins
  • Loading branch information
dbkr committed Sep 19, 2019
2 parents 00130e6 + 42b7569 commit 0e406c5
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions electron_app/src/originMigrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ async function migrateFromOldOrigin() {
webgl: false,
},
});
ipcMain.on('origin_migration_complete', (e, success, sentSummary, storedSummary) => {
const onOriginMigrationComplete = (e, success, sentSummary, storedSummary) => {
// we use once but we'll only get one of these events,
// so remove the listener for the other one
ipcMain.removeListener('origin_migration_nodata', onOriginMigrationNoData);

if (success) {
console.log("Origin migration completed successfully!");
} else {
Expand All @@ -43,12 +47,18 @@ async function migrateFromOldOrigin() {
console.error("Data stored", storedSummary);
migrateWindow.close();
resolve();
});
ipcMain.on('origin_migration_nodata', (e) => {
};
const onOriginMigrationNoData = (e, success, sentSummary, storedSummary) => {
ipcMain.removeListener('origin_migration_complete', onOriginMigrationComplete);

console.log("No session to migrate from old origin");
migrateWindow.close();
resolve();
});
};

ipcMain.once('origin_migration_complete', onOriginMigrationComplete);
ipcMain.once('origin_migration_nodata', onOriginMigrationNoData);

// Normalise the path because in the distribution, __dirname will be inside the
// electron asar.
const sourcePagePath = path.normalize(__dirname + '/../../origin_migrator/source.html');
Expand Down

0 comments on commit 0e406c5

Please sign in to comment.