Reorder IPC callbacks for settings window
This commit is contained in:
parent
5c7972893c
commit
4bed918cf8
7
main.js
7
main.js
|
@ -319,12 +319,7 @@ function handleCommonWindowEvents(window) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window.webContents) {
|
if (window.webContents) {
|
||||||
window.webContents.send('callbacks:call:setPassiveZoomFactor', [
|
window.webContents.send('callbacks:call:persistZoomFactor', [zoomFactor]);
|
||||||
zoomFactor,
|
|
||||||
]);
|
|
||||||
if (settingsWindow && settingsWindow.webContents) {
|
|
||||||
settingsWindow.webContents.send('render');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastZoomFactor = zoomFactor;
|
lastZoomFactor = zoomFactor;
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { COLORS_CHANGED, COLOR_SELECTED } from '../state/ducks/conversations';
|
||||||
export const dispatchItemsMiddleware: Middleware = ({
|
export const dispatchItemsMiddleware: Middleware = ({
|
||||||
getState,
|
getState,
|
||||||
}) => next => action => {
|
}) => next => action => {
|
||||||
|
const result = next(action);
|
||||||
if (
|
if (
|
||||||
action.type === 'items/PUT' ||
|
action.type === 'items/PUT' ||
|
||||||
action.type === 'items/PUT_EXTERNAL' ||
|
action.type === 'items/PUT_EXTERNAL' ||
|
||||||
|
@ -20,6 +21,5 @@ export const dispatchItemsMiddleware: Middleware = ({
|
||||||
) {
|
) {
|
||||||
ipcRenderer.send('preferences-changed', getState().items);
|
ipcRenderer.send('preferences-changed', getState().items);
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
return next(action);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -107,7 +107,7 @@ export type IPCEventsCallbacksType = {
|
||||||
customColor?: { id: string; value: CustomColorType }
|
customColor?: { id: string; value: CustomColorType }
|
||||||
) => void;
|
) => void;
|
||||||
getDefaultConversationColor: () => DefaultConversationColorType;
|
getDefaultConversationColor: () => DefaultConversationColorType;
|
||||||
setPassiveZoomFactor: (factor: number) => Promise<void>;
|
persistZoomFactor: (factor: number) => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ValuesWithGetters = Omit<
|
type ValuesWithGetters = Omit<
|
||||||
|
@ -507,7 +507,7 @@ export function createIPCEvents(
|
||||||
getMediaPermissions: window.getMediaPermissions,
|
getMediaPermissions: window.getMediaPermissions,
|
||||||
getMediaCameraPermissions: window.getMediaCameraPermissions,
|
getMediaCameraPermissions: window.getMediaCameraPermissions,
|
||||||
|
|
||||||
setPassiveZoomFactor: zoomFactor =>
|
persistZoomFactor: zoomFactor =>
|
||||||
window.storage.put('zoomFactor', zoomFactor),
|
window.storage.put('zoomFactor', zoomFactor),
|
||||||
|
|
||||||
...overrideEvents,
|
...overrideEvents,
|
||||||
|
|
|
@ -181,7 +181,7 @@ export function installCallback<Name extends keyof IPCEventsCallbacksType>(
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ipcRenderer.send(
|
ipcRenderer.send(
|
||||||
`callbacks:call-success;${name}`,
|
`callbacks:call-success:${name}`,
|
||||||
error && error.stack ? error.stack : error
|
error && error.stack ? error.stack : error
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ installCallback('resetAllChatColors');
|
||||||
installCallback('resetDefaultChatColor');
|
installCallback('resetDefaultChatColor');
|
||||||
installCallback('setGlobalDefaultConversationColor');
|
installCallback('setGlobalDefaultConversationColor');
|
||||||
installCallback('getDefaultConversationColor');
|
installCallback('getDefaultConversationColor');
|
||||||
installCallback('setPassiveZoomFactor');
|
installCallback('persistZoomFactor');
|
||||||
|
|
||||||
// Getters only. These are set by the primary device
|
// Getters only. These are set by the primary device
|
||||||
installSetting('blockedCount', {
|
installSetting('blockedCount', {
|
||||||
|
|
|
@ -160,7 +160,7 @@ function getSystemTraySettingValues(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
window.renderPreferences = async () => {
|
const renderPreferences = async () => {
|
||||||
if (!renderComponent) {
|
if (!renderComponent) {
|
||||||
setTimeout(window.renderPreferences, 100);
|
setTimeout(window.renderPreferences, 100);
|
||||||
return;
|
return;
|
||||||
|
@ -373,7 +373,13 @@ window.renderPreferences = async () => {
|
||||||
onUniversalExpireTimerChange: reRender(
|
onUniversalExpireTimerChange: reRender(
|
||||||
settingUniversalExpireTimer.setValue
|
settingUniversalExpireTimer.setValue
|
||||||
),
|
),
|
||||||
onZoomFactorChange: reRender(settingZoomFactor.setValue),
|
|
||||||
|
// Zoom factor change doesn't require immediate rerender since it will:
|
||||||
|
// 1. Update the zoom factor in the main window
|
||||||
|
// 2. Trigger `preferred-size-changed` in the main process
|
||||||
|
// 3. Finally result in `window.storage` update which will cause the
|
||||||
|
// rerender.
|
||||||
|
onZoomFactorChange: settingZoomFactor.setValue,
|
||||||
|
|
||||||
i18n: window.i18n,
|
i18n: window.i18n,
|
||||||
};
|
};
|
||||||
|
@ -381,11 +387,14 @@ window.renderPreferences = async () => {
|
||||||
function reRender<Value>(f: (value: Value) => Promise<Value>) {
|
function reRender<Value>(f: (value: Value) => Promise<Value>) {
|
||||||
return async (value: Value) => {
|
return async (value: Value) => {
|
||||||
await f(value);
|
await f(value);
|
||||||
window.renderPreferences();
|
renderPreferences();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
renderComponent(Preferences, props);
|
renderComponent(Preferences, props);
|
||||||
};
|
};
|
||||||
|
window.renderPreferences = renderPreferences;
|
||||||
|
|
||||||
initializeLogging();
|
initializeLogging();
|
||||||
|
|
||||||
|
ipcRenderer.on('render', () => renderPreferences());
|
||||||
|
|
Loading…
Reference in New Issue