Skip to content

Commit 0e406c5

Browse files
authored
Merge pull request element-hq#10920 from vector-im/dbkr/fix_originmigrator_electron6_2
Fix origin migrator for SSO logins
2 parents 00130e6 + 42b7569 commit 0e406c5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

electron_app/src/originMigrator.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ async function migrateFromOldOrigin() {
3333
webgl: false,
3434
},
3535
});
36-
ipcMain.on('origin_migration_complete', (e, success, sentSummary, storedSummary) => {
36+
const onOriginMigrationComplete = (e, success, sentSummary, storedSummary) => {
37+
// we use once but we'll only get one of these events,
38+
// so remove the listener for the other one
39+
ipcMain.removeListener('origin_migration_nodata', onOriginMigrationNoData);
40+
3741
if (success) {
3842
console.log("Origin migration completed successfully!");
3943
} else {
@@ -43,12 +47,18 @@ async function migrateFromOldOrigin() {
4347
console.error("Data stored", storedSummary);
4448
migrateWindow.close();
4549
resolve();
46-
});
47-
ipcMain.on('origin_migration_nodata', (e) => {
50+
};
51+
const onOriginMigrationNoData = (e, success, sentSummary, storedSummary) => {
52+
ipcMain.removeListener('origin_migration_complete', onOriginMigrationComplete);
53+
4854
console.log("No session to migrate from old origin");
4955
migrateWindow.close();
5056
resolve();
51-
});
57+
};
58+
59+
ipcMain.once('origin_migration_complete', onOriginMigrationComplete);
60+
ipcMain.once('origin_migration_nodata', onOriginMigrationNoData);
61+
5262
// Normalise the path because in the distribution, __dirname will be inside the
5363
// electron asar.
5464
const sourcePagePath = path.normalize(__dirname + '/../../origin_migrator/source.html');

0 commit comments

Comments
 (0)