mirror of
https://github.com/pavlobu/deskreen.git
synced 2025-05-28 05:10:09 -07:00
fix language change without remote
This commit is contained in:
parent
df3a37f7b8
commit
747d275add
@ -1,17 +1,13 @@
|
||||
import React, { useContext, useEffect, useState } from 'react';
|
||||
import { remote } from 'electron';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import { HTMLSelect } from '@blueprintjs/core';
|
||||
import i18n from 'i18next';
|
||||
import SharingSessionService from '../../features/SharingSessionService';
|
||||
import { SettingsContext } from '../../containers/SettingsProvider';
|
||||
import i18n_client, {
|
||||
getLangFullNameToLangISOKeyMap,
|
||||
getLangISOKeyToLangFullNameMap,
|
||||
} from '../../configs/i18next.config.client';
|
||||
|
||||
const sharingSessionService = remote.getGlobal(
|
||||
'sharingSessionService'
|
||||
) as SharingSessionService;
|
||||
import { IpcEvents } from '../../main/IpcEvents.enum';
|
||||
|
||||
export default function LanguageSelector() {
|
||||
const { setCurrentLanguageHook } = useContext(SettingsContext);
|
||||
@ -38,10 +34,7 @@ export default function LanguageSelector() {
|
||||
getLangFullNameToLangISOKeyMap().get(event.currentTarget.value) ||
|
||||
'English';
|
||||
i18n.changeLanguage(newLang);
|
||||
// TODO: call sharing sessions service here to notify all connected clients about language change
|
||||
sharingSessionService.sharingSessions.forEach((sharingSession) => {
|
||||
sharingSession?.appLanguageChanged();
|
||||
});
|
||||
ipcRenderer.invoke(IpcEvents.AppLanguageChanged);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -235,7 +235,7 @@ export default function TopPanel(props: any) {
|
||||
{renderSettingsButton()}
|
||||
</div>
|
||||
</div>
|
||||
{isConnectedDevicesDrawerOpen ? (
|
||||
{isSettingsOpen ? (
|
||||
<SettingsOverlay
|
||||
isSettingsOpen={isSettingsOpen}
|
||||
handleClose={handleSettingsClose}
|
||||
|
@ -61,19 +61,23 @@ export default class PeerConnection {
|
||||
}
|
||||
|
||||
notifyClientWithNewLanguage() {
|
||||
this.sendEncryptedMessage({
|
||||
type: 'APP_LANGUAGE',
|
||||
payload: {
|
||||
value: getAppLanguage(),
|
||||
},
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.sendEncryptedMessage({
|
||||
type: 'APP_LANGUAGE',
|
||||
payload: {
|
||||
value: getAppLanguage(),
|
||||
},
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
notifyClientWithNewColorTheme() {
|
||||
this.sendEncryptedMessage({
|
||||
type: 'APP_THEME',
|
||||
payload: { value: getAppTheme() },
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.sendEncryptedMessage({
|
||||
type: 'APP_THEME',
|
||||
payload: { value: getAppTheme() },
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
async setDesktopCapturerSourceID(id: string) {
|
||||
|
@ -12,4 +12,5 @@ export enum IpcEvents {
|
||||
GetConnectedDevices = 'get-connected-devices-list',
|
||||
DisconnectDeviceById = 'disconnect-device-by-id',
|
||||
DisconnectAllDevices = 'disconnect-all-devices',
|
||||
AppLanguageChanged = 'app-language-changed',
|
||||
}
|
||||
|
@ -179,4 +179,12 @@ export default function initIpcMainHandlers(
|
||||
ipcMain.handle(IpcEvents.DisconnectAllDevices, () => {
|
||||
getDeskreenGlobal().connectedDevicesService.disconnectAllDevices();
|
||||
});
|
||||
|
||||
ipcMain.handle(IpcEvents.AppLanguageChanged, () => {
|
||||
getDeskreenGlobal().sharingSessionService.sharingSessions.forEach(
|
||||
(sharingSession) => {
|
||||
sharingSession?.appLanguageChanged();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user