Merge pull request #7943 from vector-im/dbkr/electron_custom_protocol

Electron: Load app from custom protocol
This commit is contained in:
David Baker 2019-01-03 10:09:31 +00:00 committed by GitHub
commit 9e085511fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 544 additions and 7 deletions

View file

@ -231,7 +231,16 @@ async function loadApp() {
// set the platform for react sdk
if (window.ipcRenderer) {
console.log("Using Electron platform");
PlatformPeg.set(new ElectronPlatform());
const plaf = new ElectronPlatform();
PlatformPeg.set(plaf);
// Electron only: see if we need to do a one-time data
// migration
if (window.localStorage.getItem('mx_user_id') === null) {
console.log("Migrating session from old origin...");
await plaf.migrateFromOldOrigin();
console.log("Origin migration complete");
}
} else {
console.log("Using Web platform");
PlatformPeg.set(new WebPlatform());

View file

@ -224,6 +224,10 @@ export default class ElectronPlatform extends VectorBasePlatform {
window.location.reload(false);
}
async migrateFromOldOrigin() {
return this._ipcCall('origin_migrate');
}
async _ipcCall(name, ...args) {
const ipcCallId = ++this._nextIpcCallId;
return new Promise((resolve, reject) => {

View file

@ -149,4 +149,12 @@ export default class VectorBasePlatform extends BasePlatform {
getDefaultDeviceDisplayName(): string {
return _t("Unknown device");
}
/**
* Migrate account data from a previous origin
* Used only for the electron app
*/
async migrateFromOldOrigin() {
return false;
}
}