diff --git a/main.js b/main.js index f35a7260d7..5faa8eb806 100644 --- a/main.js +++ b/main.js @@ -907,17 +907,16 @@ function showSettingsWindow() { settingsWindow.loadURL(prepareFileUrl([__dirname, 'settings.html'])); settingsWindow.on('closed', () => { - removeDarkOverlay(); settingsWindow = null; }); - settingsWindow.once('ready-to-show', () => { - settingsWindow.show(); - settingsWindow.webContents.send('render'); - - if (config.get('openDevTools')) { - settingsWindow.webContents.openDevTools(); + ipc.once('settings-done-rendering', () => { + if (!settingsWindow) { + console.warn('settings-done-rendering: no settingsWindow available!'); + return; } + + settingsWindow.show(); }); } diff --git a/ts/components/Preferences.stories.tsx b/ts/components/Preferences.stories.tsx index 6bf8ae0a17..980921c048 100644 --- a/ts/components/Preferences.stories.tsx +++ b/ts/components/Preferences.stories.tsx @@ -103,6 +103,7 @@ const createProps = (): PropsType => ({ addCustomColor: action('addCustomColor'), closeSettings: action('closeSettings'), doDeleteAllData: action('doDeleteAllData'), + doneRendering: action('doneRendering'), editCustomColor: action('editCustomColor'), getConversationsWithCustomColor: () => Promise.resolve([]), initialSpellCheckSetting: true, diff --git a/ts/components/Preferences.tsx b/ts/components/Preferences.tsx index 7f2c83883d..add2fce550 100644 --- a/ts/components/Preferences.tsx +++ b/ts/components/Preferences.tsx @@ -78,6 +78,7 @@ export type PropsType = { addCustomColor: (color: CustomColorType) => unknown; closeSettings: () => unknown; doDeleteAllData: () => unknown; + doneRendering: () => unknown; editCustomColor: (colorId: string, color: CustomColorType) => unknown; getConversationsWithCustomColor: ( colorId: string @@ -164,6 +165,7 @@ export const Preferences = ({ defaultConversationColor, deviceName = '', doDeleteAllData, + doneRendering, editCustomColor, getConversationsWithCustomColor, hasAudioNotifications, @@ -251,6 +253,10 @@ export const Preferences = ({ document.body.classList.toggle('dark-theme', theme === ThemeType.dark); }, [theme]); + useEffect(() => { + doneRendering(); + }, [doneRendering]); + useEffect(() => { const handler = (event: KeyboardEvent) => { if (event.key === 'Escape') { diff --git a/ts/window.d.ts b/ts/window.d.ts index d46f13b2e9..cd90fe32c8 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -180,15 +180,6 @@ declare global { WhatIsThis: WhatIsThis; - SignalModule: { - registerReactRenderer: ( - f:
( - component: FunctionComponent
| ComponentClass
, - props?: (Attributes & P) | null - ) => void - ) => void; - }; - registerScreenShareControllerRenderer: ( f: ( component: typeof CallingScreenSharingController, @@ -515,6 +506,17 @@ declare global { GV2_MIGRATION_DISABLE_INVITE: boolean; RETRY_DELAY: boolean; + + // These elements are only available in the Settings window + SignalModule: { + registerReactRenderer: ( + f:
( + component: FunctionComponent
| ComponentClass
,
+ props?: (Attributes & P) | null
+ ) => void
+ ) => void;
+ };
+ renderPreferences: () => unknown;
}
// We want to extend `Error`, so we need an interface.
diff --git a/ts/windows/settings/init.ts b/ts/windows/settings/init.ts
index 09fc7a6b98..f92f2c059e 100644
--- a/ts/windows/settings/init.ts
+++ b/ts/windows/settings/init.ts
@@ -9,3 +9,5 @@ window.SignalModule.registerReactRenderer((Component, props) => {
document.getElementById('app')
);
});
+
+window.renderPreferences();
diff --git a/ts/windows/settings/preload.ts b/ts/windows/settings/preload.ts
index 4824a78cb5..2dbd329c76 100644
--- a/ts/windows/settings/preload.ts
+++ b/ts/windows/settings/preload.ts
@@ -43,6 +43,9 @@ window.ReactDOM = ReactDOM;
window.getEnvironment = getEnvironment;
window.getVersion = () => String(config.version);
window.i18n = i18n.setup(locale, localeMessages);
+function doneRendering() {
+ ipcRenderer.send('settings-done-rendering');
+}
const settingAudioNotification = createSetting('audioNotification');
const settingAutoDownloadUpdate = createSetting('autoDownloadUpdate');
@@ -157,9 +160,9 @@ function getSystemTraySettingValues(
};
}
-async function renderPreferences() {
+window.renderPreferences = async () => {
if (!renderComponent) {
- setTimeout(renderPreferences, 100);
+ setTimeout(window.renderPreferences, 100);
return;
}
@@ -293,6 +296,7 @@ async function renderPreferences() {
addCustomColor: ipcAddCustomColor,
closeSettings: () => ipcRenderer.send('close-settings'),
doDeleteAllData: () => ipcRenderer.send('delete-all-data'),
+ doneRendering,
editCustomColor: ipcEditCustomColor,
getConversationsWithCustomColor: ipcGetConversationsWithCustomColor,
initialSpellCheckSetting:
@@ -377,13 +381,11 @@ async function renderPreferences() {
function reRender