mirror of
https://github.com/pavlobu/deskreen.git
synced 2025-06-04 16:50:22 -07:00
Deskreen stepper advance removing remote
This commit is contained in:
parent
f87e74ae2a
commit
70e2c47555
@ -32,15 +32,13 @@ import ColorlibStepIcon, {
|
|||||||
} from '../components/StepperPanel/ColorlibStepIcon';
|
} from '../components/StepperPanel/ColorlibStepIcon';
|
||||||
import ColorlibConnector from '../components/StepperPanel/ColorlibConnector';
|
import ColorlibConnector from '../components/StepperPanel/ColorlibConnector';
|
||||||
import { SettingsContext } from './SettingsProvider';
|
import { SettingsContext } from './SettingsProvider';
|
||||||
import SharingSessionService from '../features/SharingSessionService';
|
|
||||||
import ConnectedDevicesService from '../features/ConnectedDevicesService';
|
|
||||||
import SharingSessionStatusEnum from '../features/SharingSessionService/SharingSessionStatusEnum';
|
import SharingSessionStatusEnum from '../features/SharingSessionService/SharingSessionStatusEnum';
|
||||||
import Logger from '../utils/LoggerWithFilePrefix';
|
import Logger from '../utils/LoggerWithFilePrefix';
|
||||||
import LanguageSelector from '../components/LanguageSelector';
|
import LanguageSelector from '../components/LanguageSelector';
|
||||||
import { getShuffledArrayOfHello } from '../configs/i18next.config.client';
|
import { getShuffledArrayOfHello } from '../configs/i18next.config.client';
|
||||||
import ToggleThemeBtnGroup from '../components/ToggleThemeBtnGroup';
|
import ToggleThemeBtnGroup from '../components/ToggleThemeBtnGroup';
|
||||||
|
import SharingSessionService from '../features/SharingSessionService';
|
||||||
const log = new Logger(__filename);
|
import ConnectedDevicesService from '../features/ConnectedDevicesService';
|
||||||
|
|
||||||
const sharingSessionService = remote.getGlobal(
|
const sharingSessionService = remote.getGlobal(
|
||||||
'sharingSessionService'
|
'sharingSessionService'
|
||||||
@ -49,6 +47,8 @@ const connectedDevicesService = remote.getGlobal(
|
|||||||
'connectedDevicesService'
|
'connectedDevicesService'
|
||||||
) as ConnectedDevicesService;
|
) as ConnectedDevicesService;
|
||||||
|
|
||||||
|
const log = new Logger(__filename);
|
||||||
|
|
||||||
const Fade = require('react-reveal/Fade');
|
const Fade = require('react-reveal/Fade');
|
||||||
|
|
||||||
const useStyles = makeStyles(() =>
|
const useStyles = makeStyles(() =>
|
||||||
@ -117,24 +117,11 @@ const DeskreenStepper = React.forwardRef((_props, ref) => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
sharingSessionService
|
ipcRenderer.invoke('create-waiting-for-connection-sharing-session');
|
||||||
.createWaitingForConnectionSharingSession()
|
ipcRenderer.on('set-pending-connection-device', (_, device) => {
|
||||||
// eslint-disable-next-line promise/always-return
|
|
||||||
.then((waitingForConnectionSharingSession) => {
|
|
||||||
waitingForConnectionSharingSession.setOnDeviceConnectedCallback(
|
|
||||||
(device: Device) => {
|
|
||||||
connectedDevicesService.setPendingConnectionDevice(device);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.catch((e) => log.error(e));
|
|
||||||
|
|
||||||
connectedDevicesService.addPendingConnectedDeviceListener(
|
|
||||||
(device: Device) => {
|
|
||||||
setPendingConnectionDevice(device);
|
setPendingConnectionDevice(device);
|
||||||
setIsAlertOpen(true);
|
setIsAlertOpen(true);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -84,49 +84,5 @@ describe('ConnectedDevicesService tests', () => {
|
|||||||
expect(isInArray).toBe(true);
|
expect(isInArray).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when .addPendingConnectedDeviceListener() was called', () => {
|
|
||||||
it('should add listener to .pendingDeviceConnectedListeners array', () => {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
const testCallback = (_: Device) => {};
|
|
||||||
|
|
||||||
service.addPendingConnectedDeviceListener(testCallback);
|
|
||||||
|
|
||||||
let isInArray = false;
|
|
||||||
service.pendingDeviceConnectedListeners.forEach((c) => {
|
|
||||||
if (c === testCallback) {
|
|
||||||
isInArray = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
expect(isInArray).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when .setPendingConnectionDevice() was called', () => {
|
|
||||||
it('should set passed device as pendingConnectionDevice and call .emitPendingConnectionDeviceConnected', () => {
|
|
||||||
service.emitPendingConnectionDeviceConnected = jest.fn();
|
|
||||||
|
|
||||||
service.setPendingConnectionDevice(testDevice);
|
|
||||||
|
|
||||||
expect(service.pendingConnectionDevice).toBe(testDevice);
|
|
||||||
expect(service.emitPendingConnectionDeviceConnected).toBeCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when .emitPendingConnectionDeviceConnected() was called', () => {
|
|
||||||
it('should call all callbacks in pendingDeviceConnectedListeners', () => {
|
|
||||||
const testCallback1 = jest.fn();
|
|
||||||
const testCallback2 = jest.fn();
|
|
||||||
service.pendingDeviceConnectedListeners = [
|
|
||||||
testCallback1,
|
|
||||||
testCallback2,
|
|
||||||
];
|
|
||||||
|
|
||||||
service.emitPendingConnectionDeviceConnected();
|
|
||||||
|
|
||||||
expect(testCallback1).toBeCalled();
|
|
||||||
expect(testCallback2).toBeCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -14,8 +14,6 @@ class ConnectedDevices {
|
|||||||
|
|
||||||
pendingConnectionDevice: Device = nullDevice;
|
pendingConnectionDevice: Device = nullDevice;
|
||||||
|
|
||||||
pendingDeviceConnectedListeners: ((device: Device) => void)[] = [];
|
|
||||||
|
|
||||||
resetPendingConnectionDevice() {
|
resetPendingConnectionDevice() {
|
||||||
this.pendingConnectionDevice = nullDevice;
|
this.pendingConnectionDevice = nullDevice;
|
||||||
}
|
}
|
||||||
@ -41,21 +39,8 @@ class ConnectedDevices {
|
|||||||
this.devices.push(device);
|
this.devices.push(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
addPendingConnectedDeviceListener(callback: (device: Device) => void) {
|
|
||||||
this.pendingDeviceConnectedListeners.push(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
setPendingConnectionDevice(device: Device) {
|
setPendingConnectionDevice(device: Device) {
|
||||||
this.pendingConnectionDevice = device;
|
this.pendingConnectionDevice = device;
|
||||||
this.emitPendingConnectionDeviceConnected();
|
|
||||||
}
|
|
||||||
|
|
||||||
emitPendingConnectionDeviceConnected() {
|
|
||||||
this.pendingDeviceConnectedListeners.forEach(
|
|
||||||
(callback: (device: Device) => void) => {
|
|
||||||
callback(this.pendingConnectionDevice);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,10 +95,6 @@ export default class DeskreenApp {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
initIpcMain() {
|
|
||||||
initIpcMainHandlers(this.mainWindow, this.latestVersion, this.appVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
async createWindow() {
|
async createWindow() {
|
||||||
if (
|
if (
|
||||||
process.env.NODE_ENV === 'development' ||
|
process.env.NODE_ENV === 'development' ||
|
||||||
@ -167,6 +163,8 @@ export default class DeskreenApp {
|
|||||||
// Remove this if your app does not use auto updates
|
// Remove this if your app does not use auto updates
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
new AppUpdater();
|
new AppUpdater();
|
||||||
|
|
||||||
|
initIpcMainHandlers(this.mainWindow, this.latestVersion, this.appVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
initI18n() {
|
initI18n() {
|
||||||
@ -205,7 +203,6 @@ export default class DeskreenApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.initElectronAppObject();
|
this.initElectronAppObject();
|
||||||
this.initIpcMain();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,12 +6,13 @@ import SharingSession from '../features/SharingSessionService/SharingSession';
|
|||||||
import RoomIDService from '../server/RoomIDService';
|
import RoomIDService from '../server/RoomIDService';
|
||||||
import getDeskreenGlobal from '../utils/mainProcessHelpers/getDeskreenGlobal';
|
import getDeskreenGlobal from '../utils/mainProcessHelpers/getDeskreenGlobal';
|
||||||
import signalingServer from '../server';
|
import signalingServer from '../server';
|
||||||
import { DeskreenGlobalService } from '../utils/mainProcessHelpers/DeskreenGlobalService.enum';
|
import Logger from '../utils/LoggerWithFilePrefix';
|
||||||
|
|
||||||
|
const log = new Logger(__filename);
|
||||||
const v4IPGetter = require('internal-ip').v4;
|
const v4IPGetter = require('internal-ip').v4;
|
||||||
|
|
||||||
export default function initIpcMainHandlers(
|
export default function initIpcMainHandlers(
|
||||||
mainWindow: BrowserWindow | null,
|
mainWindow: BrowserWindow,
|
||||||
latestVersion: string,
|
latestVersion: string,
|
||||||
appVersion: string
|
appVersion: string
|
||||||
) {
|
) {
|
||||||
@ -90,4 +91,25 @@ export default function initIpcMainHandlers(
|
|||||||
const deskreenGlobal = getDeskreenGlobal();
|
const deskreenGlobal = getDeskreenGlobal();
|
||||||
deskreenGlobal.roomIDService.unmarkRoomIDAsTaken(roomID);
|
deskreenGlobal.roomIDService.unmarkRoomIDAsTaken(roomID);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.handle('create-waiting-for-connection-sharing-session', () => {
|
||||||
|
console.log('handle create-waiting-for-connection-sharing-session');
|
||||||
|
getDeskreenGlobal()
|
||||||
|
.sharingSessionService.createWaitingForConnectionSharingSession()
|
||||||
|
// eslint-disable-next-line promise/always-return
|
||||||
|
.then((waitingForConnectionSharingSession) => {
|
||||||
|
waitingForConnectionSharingSession.setOnDeviceConnectedCallback(
|
||||||
|
(device: Device) => {
|
||||||
|
getDeskreenGlobal().connectedDevicesService.setPendingConnectionDevice(
|
||||||
|
device
|
||||||
|
);
|
||||||
|
mainWindow.webContents.send(
|
||||||
|
'set-pending-connection-device',
|
||||||
|
device
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.catch((e) => log.error(e));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user