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