mirror of
https://github.com/pavlobu/deskreen.git
synced 2025-05-29 13:50: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: {
|
waitingForConnectionSharingSession: {
|
||||||
callPeer: jest.fn(),
|
callPeer: jest.fn(),
|
||||||
},
|
},
|
||||||
changeSharingSessionStatusToSharing: jest.fn(),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { remote } from 'electron';
|
import { ipcRenderer, remote } from 'electron';
|
||||||
import { Button, Text } from '@blueprintjs/core';
|
import { Button, Text } from '@blueprintjs/core';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { TFunction } from 'i18next';
|
import { TFunction } from 'i18next';
|
||||||
@ -9,11 +9,8 @@ import ScanQRStep from './ScanQRStep';
|
|||||||
import ChooseAppOrScreeenStep from './ChooseAppOrScreeenStep';
|
import ChooseAppOrScreeenStep from './ChooseAppOrScreeenStep';
|
||||||
import ConfirmStep from './ConfirmStep';
|
import ConfirmStep from './ConfirmStep';
|
||||||
import ConnectedDevicesService from '../../features/ConnectedDevicesService';
|
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(
|
const connectedDevicesService = remote.getGlobal(
|
||||||
'connectedDevicesService'
|
'connectedDevicesService'
|
||||||
) as 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>
|
||||||
activeStep !== 0 ? (
|
<Col xs={12}>
|
||||||
<Row>
|
<Button
|
||||||
<Col xs={12}>
|
intent={activeStep === 2 ? 'success' : 'none'}
|
||||||
<Button
|
onClick={async () => {
|
||||||
intent={activeStep === 2 ? 'success' : 'none'}
|
handleNext();
|
||||||
onClick={async () => {
|
if (isConfirmStep(activeStep, steps)) {
|
||||||
handleNext();
|
ipcRenderer.invoke(
|
||||||
if (isConfirmStep(activeStep, steps)) {
|
IpcEvents.StartSharingOnWaitingForConnectionSharingSession
|
||||||
if (
|
);
|
||||||
sharingSessionService.waitingForConnectionSharingSession !==
|
resetPendingConnectionDevice();
|
||||||
null
|
resetUserAllowedConnection();
|
||||||
) {
|
|
||||||
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'
|
|
||||||
}
|
}
|
||||||
>
|
}}
|
||||||
{isConfirmStep(activeStep, steps)
|
style={{
|
||||||
? t('Confirm Button Text')
|
display: activeStep === 1 ? 'none' : 'inline',
|
||||||
: 'Next'}
|
borderRadius: '100px',
|
||||||
</Button>
|
width: '300px',
|
||||||
</Col>
|
textAlign: 'center',
|
||||||
</Row>
|
}}
|
||||||
) : (
|
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' }}>
|
<Row style={{ display: activeStep === 2 ? 'inline-block' : 'none' }}>
|
||||||
<Button
|
<Button
|
||||||
intent="danger"
|
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', () => {
|
describe('when waitWhileUserIsNotCreated is called', () => {
|
||||||
it('should wait until user is created then call clearInterval', () => {
|
it('should wait until user is created then call clearInterval', () => {
|
||||||
const testUser = {
|
const testUser = {
|
||||||
|
@ -86,11 +86,6 @@ export default class SharingSessionService {
|
|||||||
return sharingSession;
|
return sharingSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line class-methods-use-this
|
|
||||||
changeSharingSessionStatusToSharing(sharingSession: SharingSession) {
|
|
||||||
sharingSession.status = SharingSessionStatusEnum.SHARING;
|
|
||||||
}
|
|
||||||
|
|
||||||
pollForInactiveSessions(): void {
|
pollForInactiveSessions(): void {
|
||||||
[...this.sharingSessions.keys()].forEach((key) => {
|
[...this.sharingSessions.keys()].forEach((key) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -15,4 +15,5 @@ export enum IpcEvents {
|
|||||||
AppLanguageChanged = 'app-language-changed',
|
AppLanguageChanged = 'app-language-changed',
|
||||||
GetDesktopCapturerServiceSourcesMap = 'get-desktop-capturer-service-sources-map',
|
GetDesktopCapturerServiceSourcesMap = 'get-desktop-capturer-service-sources-map',
|
||||||
GetWaitingForConnectionSharingSessionSourceId = 'get-waiting-for-connection-sharing-session-source-id',
|
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: {
|
source: {
|
||||||
thumbnail: source?.source.thumbnail?.toDataURL(),
|
thumbnail: source?.source.thumbnail?.toDataURL(),
|
||||||
appIcon: source?.source.appIcon?.toDataURL(),
|
appIcon: source?.source.appIcon?.toDataURL(),
|
||||||
|
name: source?.source.name,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -214,4 +215,20 @@ export default function initIpcMainHandlers(
|
|||||||
.waitingForConnectionSharingSession?.desktopCapturerSourceID;
|
.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