mirror of
https://github.com/pavlobu/deskreen.git
synced 2025-05-31 23:00:09 -07:00
remove last remote call on theme change
This commit is contained in:
parent
5188c499cf
commit
b531db3dbf
@ -1,12 +1,8 @@
|
|||||||
import { remote } from 'electron';
|
|
||||||
import React, { useContext, useCallback } from 'react';
|
import React, { useContext, useCallback } from 'react';
|
||||||
import { Button, Classes, ControlGroup } from '@blueprintjs/core';
|
import { Button, Classes, ControlGroup } from '@blueprintjs/core';
|
||||||
import SharingSessionService from '../../features/SharingSessionService';
|
import { ipcRenderer } from 'electron';
|
||||||
import { SettingsContext } from '../../containers/SettingsProvider';
|
import { SettingsContext } from '../../containers/SettingsProvider';
|
||||||
|
import { IpcEvents } from '../../main/IpcEvents.enum';
|
||||||
const sharingSessionService = remote.getGlobal(
|
|
||||||
'sharingSessionService'
|
|
||||||
) as SharingSessionService;
|
|
||||||
|
|
||||||
export default function ToggleThemeBtnGroup() {
|
export default function ToggleThemeBtnGroup() {
|
||||||
const { isDarkTheme, setIsDarkThemeHook } = useContext(SettingsContext);
|
const { isDarkTheme, setIsDarkThemeHook } = useContext(SettingsContext);
|
||||||
@ -16,9 +12,7 @@ export default function ToggleThemeBtnGroup() {
|
|||||||
document.body.classList.toggle(Classes.DARK);
|
document.body.classList.toggle(Classes.DARK);
|
||||||
setIsDarkThemeHook(true);
|
setIsDarkThemeHook(true);
|
||||||
}
|
}
|
||||||
sharingSessionService.sharingSessions.forEach((sharingSession) => {
|
ipcRenderer.invoke(IpcEvents.NotifyAllSessionsWithAppThemeChanged);
|
||||||
sharingSession?.appThemeChanged();
|
|
||||||
});
|
|
||||||
}, [isDarkTheme, setIsDarkThemeHook]);
|
}, [isDarkTheme, setIsDarkThemeHook]);
|
||||||
|
|
||||||
const handleToggleLightTheme = useCallback(() => {
|
const handleToggleLightTheme = useCallback(() => {
|
||||||
@ -26,9 +20,7 @@ export default function ToggleThemeBtnGroup() {
|
|||||||
document.body.classList.toggle(Classes.DARK);
|
document.body.classList.toggle(Classes.DARK);
|
||||||
setIsDarkThemeHook(false);
|
setIsDarkThemeHook(false);
|
||||||
}
|
}
|
||||||
sharingSessionService.sharingSessions.forEach((sharingSession) => {
|
ipcRenderer.invoke(IpcEvents.NotifyAllSessionsWithAppThemeChanged);
|
||||||
sharingSession?.appThemeChanged();
|
|
||||||
});
|
|
||||||
}, [isDarkTheme, setIsDarkThemeHook]);
|
}, [isDarkTheme, setIsDarkThemeHook]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -20,4 +20,5 @@ export enum IpcEvents {
|
|||||||
GetWaitingForConnectionSharingSessionRoomId = 'get-waiting-for-connection-sharing-session-room-id',
|
GetWaitingForConnectionSharingSessionRoomId = 'get-waiting-for-connection-sharing-session-room-id',
|
||||||
GetDesktopSharingSourceIds = 'get-desktop-sharing-source-ids',
|
GetDesktopSharingSourceIds = 'get-desktop-sharing-source-ids',
|
||||||
SetDesktopCapturerSourceId = 'set-desktop-capturer-source-id',
|
SetDesktopCapturerSourceId = 'set-desktop-capturer-source-id',
|
||||||
|
NotifyAllSessionsWithAppThemeChanged = 'notify-all-sessions-with-app-theme-changed',
|
||||||
}
|
}
|
||||||
|
@ -266,4 +266,12 @@ export default function initIpcMainHandlers(
|
|||||||
id
|
id
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.handle(IpcEvents.NotifyAllSessionsWithAppThemeChanged, () => {
|
||||||
|
getDeskreenGlobal().sharingSessionService.sharingSessions.forEach(
|
||||||
|
(sharingSession) => {
|
||||||
|
sharingSession?.appThemeChanged();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user