mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-18 23:44:59 +01:00
Merge branch 'dbkr/rebrand_step_2' into 'develop'
Rebrand step 2 See merge request new-vector/element/element-desktop!2
This commit is contained in:
commit
fdb02b93e5
@ -105,8 +105,26 @@ if (userDataPathInProtocol) {
|
||||
app.setPath('userData', userDataPathInProtocol);
|
||||
} else if (argv['profile-dir']) {
|
||||
app.setPath('userData', argv['profile-dir']);
|
||||
} else if (argv['profile']) {
|
||||
app.setPath('userData', `${app.getPath('userData')}-${argv['profile']}`);
|
||||
} else {
|
||||
let newUserDataPath = app.getPath('userData');
|
||||
if (argv['profile']) {
|
||||
newUserDataPath += '-' + argv['profile'];
|
||||
}
|
||||
// Electron creates the user data directory (with just an empty 'Dictionaries' directory...)
|
||||
// as soon as the app path is set, so pick a random path in it that must exist if it's a
|
||||
// real user data directory.
|
||||
function isRealUserDataDir(d) {
|
||||
return fs.existsSync(path.join(d, 'IndexedDB'));
|
||||
}
|
||||
const newUserDataPathExists = isRealUserDataDir(newUserDataPath);
|
||||
const oldUserDataPath = path.join(app.getPath('appData'), 'Riot');
|
||||
const oldUserDataPathExists = isRealUserDataDir(oldUserDataPath);
|
||||
console.log(newUserDataPath + " exists: " + (newUserDataPathExists ? 'yes' : 'no'));
|
||||
console.log(oldUserDataPath + " exists: " + (oldUserDataPathExists ? 'yes' : 'no'));
|
||||
if (!newUserDataPathExists && oldUserDataPathExists) {
|
||||
console.log("Using legacy user data path: " + oldUserDataPath);
|
||||
app.setPath('userData', oldUserDataPath);
|
||||
}
|
||||
}
|
||||
|
||||
async function tryPaths(name, root, rawPaths) {
|
||||
@ -191,7 +209,7 @@ async function setupGlobals() {
|
||||
|
||||
// launcher
|
||||
launcher = new AutoLaunch({
|
||||
name: vectorConfig.brand || 'Riot',
|
||||
name: vectorConfig.brand || 'Element',
|
||||
isHidden: true,
|
||||
mac: {
|
||||
useLaunchAgent: true,
|
||||
@ -199,6 +217,25 @@ async function setupGlobals() {
|
||||
});
|
||||
}
|
||||
|
||||
async function moveAutoLauncher() {
|
||||
// Look for an auto-launcher under 'Riot' and if we find one, port it's
|
||||
// enabled/disbaledp-ness over to the new 'Element' launcher
|
||||
if (!vectorConfig.brand || vectorConfig.brand === 'Element') {
|
||||
const oldLauncher = new AutoLaunch({
|
||||
name: 'Riot',
|
||||
isHidden: true,
|
||||
mac: {
|
||||
useLaunchAgent: true,
|
||||
},
|
||||
});
|
||||
const wasEnabled = await oldLauncher.isEnabled();
|
||||
if (wasEnabled) {
|
||||
await oldLauncher.disable();
|
||||
await launcher.enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const eventStorePath = path.join(app.getPath('userData'), 'EventStore');
|
||||
const store = new Store({ name: "electron-config" });
|
||||
|
||||
@ -377,7 +414,12 @@ ipcMain.on('ipcCall', async function(ev, payload) {
|
||||
|
||||
case 'getPickleKey':
|
||||
try {
|
||||
ret = await keytar.getPassword("riot.im", `${args[0]}|${args[1]}`);
|
||||
ret = await keytar.getPassword("element.io", `${args[0]}|${args[1]}`);
|
||||
// migrate from riot.im (remove once we think there will no longer be
|
||||
// logins from the time of riot.im)
|
||||
if (ret === null) {
|
||||
ret = await keytar.getPassword("riot.im", `${args[0]}|${args[1]}`);
|
||||
}
|
||||
} catch (e) {
|
||||
// if an error is thrown (e.g. keytar can't connect to the keychain),
|
||||
// then return null, which means the default pickle key will be used
|
||||
@ -397,7 +439,7 @@ ipcMain.on('ipcCall', async function(ev, payload) {
|
||||
});
|
||||
});
|
||||
const pickleKey = randomArray.toString("base64").replace(/=+$/g, '');
|
||||
await keytar.setPassword("riot.im", `${args[0]}|${args[1]}`, pickleKey);
|
||||
await keytar.setPassword("element.io", `${args[0]}|${args[1]}`, pickleKey);
|
||||
ret = pickleKey;
|
||||
} catch (e) {
|
||||
ret = null;
|
||||
@ -406,6 +448,9 @@ ipcMain.on('ipcCall', async function(ev, payload) {
|
||||
|
||||
case 'destroyPickleKey':
|
||||
try {
|
||||
await keytar.deletePassword("element.io", `${args[0]}|${args[1]}`);
|
||||
// migrate from riot.im (remove once we think there will no longer be
|
||||
// logins from the time of riot.im)
|
||||
await keytar.deletePassword("riot.im", `${args[0]}|${args[1]}`);
|
||||
} catch (e) {}
|
||||
break;
|
||||
@ -711,6 +756,7 @@ app.enableSandbox();
|
||||
app.on('ready', async () => {
|
||||
try {
|
||||
await setupGlobals();
|
||||
await moveAutoLauncher();
|
||||
} catch (e) {
|
||||
console.log("App setup failed: exiting", e);
|
||||
process.exit(1);
|
||||
|
Loading…
Reference in New Issue
Block a user