mirror of
https://github.com/pavlobu/deskreen.git
synced 2025-05-27 21:00:08 -07:00
remove sharing session from IntermediateStep
This commit is contained in:
parent
35d6fd825c
commit
4ab3668532
@ -25,7 +25,6 @@ jest.mock('electron', () => {
|
||||
waitingForConnectionSharingSession: {
|
||||
callPeer: jest.fn(),
|
||||
},
|
||||
changeSharingSessionStatusToSharing: jest.fn(),
|
||||
};
|
||||
}
|
||||
return {};
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { remote } from 'electron';
|
||||
import { ipcRenderer, remote } from 'electron';
|
||||
import { Button, Text } from '@blueprintjs/core';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { TFunction } from 'i18next';
|
||||
@ -9,11 +9,8 @@ import ScanQRStep from './ScanQRStep';
|
||||
import ChooseAppOrScreeenStep from './ChooseAppOrScreeenStep';
|
||||
import ConfirmStep from './ConfirmStep';
|
||||
import ConnectedDevicesService from '../../features/ConnectedDevicesService';
|
||||
import SharingSessionService from '../../features/SharingSessionService';
|
||||
import { IpcEvents } from '../../main/IpcEvents.enum';
|
||||
|
||||
const sharingSessionService = remote.getGlobal(
|
||||
'sharingSessionService'
|
||||
) as SharingSessionService;
|
||||
const connectedDevicesService = remote.getGlobal(
|
||||
'connectedDevicesService'
|
||||
) as ConnectedDevicesService;
|
||||
@ -126,73 +123,43 @@ export default function IntermediateStep(props: IntermediateStepProps) {
|
||||
) : (
|
||||
<></>
|
||||
)
|
||||
// activeStep === 0 ? (
|
||||
// <Button
|
||||
// onClick={() => {
|
||||
// connectDevice(
|
||||
// // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// // @ts-ignore
|
||||
// DEVICES[Math.floor(Math.random() * DEVICES.length)]
|
||||
// );
|
||||
// }}
|
||||
// >
|
||||
// Connect Test Device
|
||||
// </Button>
|
||||
// ) : (
|
||||
// <></>
|
||||
// )
|
||||
}
|
||||
{
|
||||
/**/
|
||||
activeStep !== 0 ? (
|
||||
<Row>
|
||||
<Col xs={12}>
|
||||
<Button
|
||||
intent={activeStep === 2 ? 'success' : 'none'}
|
||||
onClick={async () => {
|
||||
handleNext();
|
||||
if (isConfirmStep(activeStep, steps)) {
|
||||
if (
|
||||
sharingSessionService.waitingForConnectionSharingSession !==
|
||||
null
|
||||
) {
|
||||
const sharingSession =
|
||||
sharingSessionService.waitingForConnectionSharingSession;
|
||||
sharingSession.callPeer();
|
||||
sharingSessionService.changeSharingSessionStatusToSharing(
|
||||
sharingSession
|
||||
);
|
||||
}
|
||||
connectedDevicesService.addDevice(
|
||||
connectedDevicesService.pendingConnectionDevice
|
||||
);
|
||||
connectedDevicesService.resetPendingConnectionDevice();
|
||||
resetPendingConnectionDevice();
|
||||
resetUserAllowedConnection();
|
||||
}
|
||||
}}
|
||||
style={{
|
||||
display: activeStep === 1 ? 'none' : 'inline',
|
||||
borderRadius: '100px',
|
||||
width: '300px',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
rightIcon={
|
||||
isConfirmStep(activeStep, steps)
|
||||
? 'small-tick'
|
||||
: 'chevron-right'
|
||||
{activeStep !== 0 ? (
|
||||
<Row>
|
||||
<Col xs={12}>
|
||||
<Button
|
||||
intent={activeStep === 2 ? 'success' : 'none'}
|
||||
onClick={async () => {
|
||||
handleNext();
|
||||
if (isConfirmStep(activeStep, steps)) {
|
||||
ipcRenderer.invoke(
|
||||
IpcEvents.StartSharingOnWaitingForConnectionSharingSession
|
||||
);
|
||||
resetPendingConnectionDevice();
|
||||
resetUserAllowedConnection();
|
||||
}
|
||||
>
|
||||
{isConfirmStep(activeStep, steps)
|
||||
? t('Confirm Button Text')
|
||||
: 'Next'}
|
||||
</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
) : (
|
||||
<></>
|
||||
)
|
||||
}
|
||||
}}
|
||||
style={{
|
||||
display: activeStep === 1 ? 'none' : 'inline',
|
||||
borderRadius: '100px',
|
||||
width: '300px',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
rightIcon={
|
||||
isConfirmStep(activeStep, steps)
|
||||
? 'small-tick'
|
||||
: 'chevron-right'
|
||||
}
|
||||
>
|
||||
{isConfirmStep(activeStep, steps)
|
||||
? t('Confirm Button Text')
|
||||
: 'Next'}
|
||||
</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
<Row style={{ display: activeStep === 2 ? 'inline-block' : 'none' }}>
|
||||
<Button
|
||||
intent="danger"
|
||||
|
@ -157,20 +157,6 @@ describe('SharingSessionService unit tests', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when changeSharingSessionStatusToSharing is called', () => {
|
||||
it('should change passed sharingSession status to SHARING', () => {
|
||||
const testSharingSession = ({
|
||||
status: 'dummystatus',
|
||||
} as unknown) as SharingSession;
|
||||
|
||||
sharingSessionService.changeSharingSessionStatusToSharing(
|
||||
testSharingSession
|
||||
);
|
||||
|
||||
expect(testSharingSession.status).toBe(SharingSessionStatusEnum.SHARING);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when waitWhileUserIsNotCreated is called', () => {
|
||||
it('should wait until user is created then call clearInterval', () => {
|
||||
const testUser = {
|
||||
|
@ -86,11 +86,6 @@ export default class SharingSessionService {
|
||||
return sharingSession;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
changeSharingSessionStatusToSharing(sharingSession: SharingSession) {
|
||||
sharingSession.status = SharingSessionStatusEnum.SHARING;
|
||||
}
|
||||
|
||||
pollForInactiveSessions(): void {
|
||||
[...this.sharingSessions.keys()].forEach((key) => {
|
||||
// @ts-ignore
|
||||
|
@ -15,4 +15,5 @@ export enum IpcEvents {
|
||||
AppLanguageChanged = 'app-language-changed',
|
||||
GetDesktopCapturerServiceSourcesMap = 'get-desktop-capturer-service-sources-map',
|
||||
GetWaitingForConnectionSharingSessionSourceId = 'get-waiting-for-connection-sharing-session-source-id',
|
||||
StartSharingOnWaitingForConnectionSharingSession = 'start-sharing-on-waiting-for-connection-sharing-session',
|
||||
}
|
||||
|
@ -201,6 +201,7 @@ export default function initIpcMainHandlers(
|
||||
source: {
|
||||
thumbnail: source?.source.thumbnail?.toDataURL(),
|
||||
appIcon: source?.source.appIcon?.toDataURL(),
|
||||
name: source?.source.name,
|
||||
},
|
||||
};
|
||||
}
|
||||
@ -214,4 +215,20 @@ export default function initIpcMainHandlers(
|
||||
.waitingForConnectionSharingSession?.desktopCapturerSourceID;
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
IpcEvents.StartSharingOnWaitingForConnectionSharingSession,
|
||||
() => {
|
||||
const sharingSession = getDeskreenGlobal().sharingSessionService
|
||||
.waitingForConnectionSharingSession;
|
||||
if (sharingSession !== null) {
|
||||
sharingSession.callPeer();
|
||||
sharingSession.status = SharingSessionStatusEnum.SHARING;
|
||||
}
|
||||
getDeskreenGlobal().connectedDevicesService.addDevice(
|
||||
getDeskreenGlobal().connectedDevicesService.pendingConnectionDevice
|
||||
);
|
||||
getDeskreenGlobal().connectedDevicesService.resetPendingConnectionDevice();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user