mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-27 01:11:13 -06:00
Cleanup showScreenSharingIndicator method (#2062)
This commit is contained in:
parent
ff182adfa1
commit
dee181592f
@ -313,10 +313,12 @@ export enum NotificationActions {
|
|||||||
* Screen sharing Indicator
|
* Screen sharing Indicator
|
||||||
*/
|
*/
|
||||||
export interface IScreenSharingIndicatorOptions {
|
export interface IScreenSharingIndicatorOptions {
|
||||||
|
// id of the display that is being shared
|
||||||
displayId: string;
|
displayId: string;
|
||||||
|
|
||||||
requestId: number;
|
requestId: number;
|
||||||
|
|
||||||
streamId: string;
|
streamId: string;
|
||||||
stream?: MediaStream;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IVersionInfo {
|
export interface IVersionInfo {
|
||||||
|
@ -512,12 +512,9 @@ export class SSFApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a banner that informs user that the screen is being shared.
|
* Shows a banner that informs the user that the screen is being shared.
|
||||||
*
|
*
|
||||||
* @param options object with following fields:
|
* @param options
|
||||||
* - stream https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/MediaStream object.
|
|
||||||
* The indicator automatically destroys itself when stream becomes inactive (see MediaStream.active).
|
|
||||||
* - displayId id of the display that is being shared or that contains the shared app
|
|
||||||
* @param callback callback function that will be called to handle events.
|
* @param callback callback function that will be called to handle events.
|
||||||
* Callback receives event object { type: string }. Types:
|
* Callback receives event object { type: string }. Types:
|
||||||
* - 'error' - error occured. Event object contains 'reason' field.
|
* - 'error' - error occured. Event object contains 'reason' field.
|
||||||
@ -527,31 +524,25 @@ export class SSFApi {
|
|||||||
options: IScreenSharingIndicatorOptions,
|
options: IScreenSharingIndicatorOptions,
|
||||||
callback,
|
callback,
|
||||||
): void {
|
): void {
|
||||||
const { displayId, stream } = options;
|
const { displayId, streamId } = options;
|
||||||
|
|
||||||
if (!stream || !stream.active || stream.getVideoTracks().length !== 1) {
|
if (streamId && typeof streamId !== 'string') {
|
||||||
callback({ type: 'error', reason: 'bad stream' });
|
callback({ type: 'error', reason: 'bad streamId' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (displayId && typeof displayId !== 'string') {
|
if (displayId && typeof displayId !== 'string') {
|
||||||
callback({ type: 'error', reason: 'bad displayId' });
|
callback({ type: 'error', reason: 'bad displayId' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const destroy = () => {
|
|
||||||
throttledCloseScreenShareIndicator(stream.id);
|
|
||||||
stream.removeEventListener('inactive', destroy);
|
|
||||||
};
|
|
||||||
|
|
||||||
stream.addEventListener('inactive', destroy);
|
|
||||||
|
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
local.screenSharingIndicatorCallback = callback;
|
local.screenSharingIndicatorCallback = callback;
|
||||||
ipcRenderer.send(apiName.symphonyApi, {
|
ipcRenderer.send(apiName.symphonyApi, {
|
||||||
cmd: apiCmds.openScreenSharingIndicator,
|
cmd: apiCmds.openScreenSharingIndicator,
|
||||||
displayId,
|
displayId,
|
||||||
id: ++nextIndicatorId,
|
id: ++nextIndicatorId,
|
||||||
streamId: stream.id,
|
streamId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user