2023-06-30 11:07:04 -08:00
|
|
|
import {require as remoteRequire, getCurrentWindow} from '@electron/remote';
|
2019-10-25 04:34:52 -08:00
|
|
|
// TODO: Should be updates to new async API https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31
|
2016-09-21 06:27:11 -08:00
|
|
|
|
2023-07-25 09:30:19 -08:00
|
|
|
import {ipcRenderer} from './ipc';
|
|
|
|
|
|
2021-11-22 18:50:10 -09:00
|
|
|
const plugins = remoteRequire('./plugins') as typeof import('../../app/plugins');
|
2016-07-13 12:44:24 -08:00
|
|
|
|
2023-06-30 11:07:04 -08:00
|
|
|
Object.defineProperty(window, 'profileName', {
|
|
|
|
|
get() {
|
|
|
|
|
return getCurrentWindow().profileName;
|
|
|
|
|
},
|
|
|
|
|
set() {
|
|
|
|
|
throw new Error('profileName is readonly');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2016-09-21 06:27:11 -08:00
|
|
|
export function getConfig() {
|
2023-06-30 11:07:04 -08:00
|
|
|
return plugins.getDecoratedConfig(window.profileName);
|
2016-07-13 12:44:24 -08:00
|
|
|
}
|
|
|
|
|
|
2019-10-12 02:16:45 -08:00
|
|
|
export function subscribe(fn: (event: Electron.IpcRendererEvent, ...args: any[]) => void) {
|
2016-07-13 12:44:24 -08:00
|
|
|
ipcRenderer.on('config change', fn);
|
2016-07-16 10:57:42 -08:00
|
|
|
ipcRenderer.on('plugins change', fn);
|
2016-07-13 12:44:24 -08:00
|
|
|
return () => {
|
|
|
|
|
ipcRenderer.removeListener('config change', fn);
|
|
|
|
|
};
|
|
|
|
|
}
|