mirror of
https://github.com/pavlobu/deskreen.git
synced 2025-06-09 03:00:10 -07:00
remove globals, more invokes
This commit is contained in:
parent
19a1da6ff3
commit
eac9649c5a
@ -206,30 +206,8 @@ const DeskreenStepper = React.forwardRef((_props, ref) => {
|
|||||||
const handleCancelAlert = async () => {
|
const handleCancelAlert = async () => {
|
||||||
setIsAlertOpen(false);
|
setIsAlertOpen(false);
|
||||||
|
|
||||||
if (sharingSessionService.waitingForConnectionSharingSession !== null) {
|
ipcRenderer.invoke(IpcEvents.ResetWaitingForConnectionSharingSession);
|
||||||
const sharingSession =
|
ipcRenderer.invoke(IpcEvents.CreateWaitingForConnectionSharingSession);
|
||||||
sharingSessionService.waitingForConnectionSharingSession;
|
|
||||||
sharingSession.denyConnectionForPartner();
|
|
||||||
sharingSession.destroy();
|
|
||||||
sharingSession.setStatus(SharingSessionStatusEnum.NOT_CONNECTED);
|
|
||||||
sharingSessionService.sharingSessions.delete(sharingSession.id);
|
|
||||||
|
|
||||||
const prevRoomID =
|
|
||||||
sharingSessionService.waitingForConnectionSharingSession.roomID;
|
|
||||||
|
|
||||||
sharingSessionService.waitingForConnectionSharingSession = null;
|
|
||||||
sharingSessionService
|
|
||||||
.createWaitingForConnectionSharingSession(prevRoomID)
|
|
||||||
// eslint-disable-next-line promise/always-return
|
|
||||||
.then((waitingForConnectionSharingSession) => {
|
|
||||||
waitingForConnectionSharingSession.setOnDeviceConnectedCallback(
|
|
||||||
(device: Device) => {
|
|
||||||
connectedDevicesService.setPendingConnectionDevice(device);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.catch((e) => log.error(e));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirmAlert = useCallback(async () => {
|
const handleConfirmAlert = useCallback(async () => {
|
||||||
|
@ -8,6 +8,7 @@ import getDeskreenGlobal from '../utils/mainProcessHelpers/getDeskreenGlobal';
|
|||||||
import signalingServer from '../server';
|
import signalingServer from '../server';
|
||||||
import Logger from '../utils/LoggerWithFilePrefix';
|
import Logger from '../utils/LoggerWithFilePrefix';
|
||||||
import { IpcEvents } from './IpcEvents.enum';
|
import { IpcEvents } from './IpcEvents.enum';
|
||||||
|
import SharingSessionStatusEnum from '../features/SharingSessionService/SharingSessionStatusEnum';
|
||||||
|
|
||||||
const log = new Logger(__filename);
|
const log = new Logger(__filename);
|
||||||
const v4IPGetter = require('internal-ip').v4;
|
const v4IPGetter = require('internal-ip').v4;
|
||||||
@ -93,21 +94,20 @@ export default function initIpcMainHandlers(
|
|||||||
deskreenGlobal.roomIDService.unmarkRoomIDAsTaken(roomID);
|
deskreenGlobal.roomIDService.unmarkRoomIDAsTaken(roomID);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function onDeviceConnectedCallback(device: Device): void {
|
||||||
|
getDeskreenGlobal().connectedDevicesService.setPendingConnectionDevice(
|
||||||
|
device
|
||||||
|
);
|
||||||
|
mainWindow.webContents.send(IpcEvents.SetPendingConnectionDevice, device);
|
||||||
|
}
|
||||||
|
|
||||||
ipcMain.handle(IpcEvents.CreateWaitingForConnectionSharingSession, () => {
|
ipcMain.handle(IpcEvents.CreateWaitingForConnectionSharingSession, () => {
|
||||||
getDeskreenGlobal()
|
getDeskreenGlobal()
|
||||||
.sharingSessionService.createWaitingForConnectionSharingSession()
|
.sharingSessionService.createWaitingForConnectionSharingSession()
|
||||||
// eslint-disable-next-line promise/always-return
|
// eslint-disable-next-line promise/always-return
|
||||||
.then((waitingForConnectionSharingSession) => {
|
.then((waitingForConnectionSharingSession) => {
|
||||||
waitingForConnectionSharingSession.setOnDeviceConnectedCallback(
|
waitingForConnectionSharingSession.setOnDeviceConnectedCallback(
|
||||||
(device: Device) => {
|
onDeviceConnectedCallback
|
||||||
getDeskreenGlobal().connectedDevicesService.setPendingConnectionDevice(
|
|
||||||
device
|
|
||||||
);
|
|
||||||
mainWindow.webContents.send(
|
|
||||||
IpcEvents.SetPendingConnectionDevice,
|
|
||||||
device
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch((e) => log.error(e));
|
.catch((e) => log.error(e));
|
||||||
@ -118,6 +118,7 @@ export default function initIpcMainHandlers(
|
|||||||
.waitingForConnectionSharingSession;
|
.waitingForConnectionSharingSession;
|
||||||
sharingSession?.disconnectByHostMachineUser();
|
sharingSession?.disconnectByHostMachineUser();
|
||||||
sharingSession?.destroy();
|
sharingSession?.destroy();
|
||||||
|
sharingSession?.setStatus(SharingSessionStatusEnum.NOT_CONNECTED);
|
||||||
getDeskreenGlobal().sharingSessionService.sharingSessions.delete(
|
getDeskreenGlobal().sharingSessionService.sharingSessions.delete(
|
||||||
sharingSession?.id as string
|
sharingSession?.id as string
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user