mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-26 08:51:22 -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
|
||||
*/
|
||||
export interface IScreenSharingIndicatorOptions {
|
||||
// id of the display that is being shared
|
||||
displayId: string;
|
||||
|
||||
requestId: number;
|
||||
|
||||
streamId: string;
|
||||
stream?: MediaStream;
|
||||
}
|
||||
|
||||
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:
|
||||
* - 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 options
|
||||
* @param callback callback function that will be called to handle events.
|
||||
* Callback receives event object { type: string }. Types:
|
||||
* - 'error' - error occured. Event object contains 'reason' field.
|
||||
@ -527,31 +524,25 @@ export class SSFApi {
|
||||
options: IScreenSharingIndicatorOptions,
|
||||
callback,
|
||||
): void {
|
||||
const { displayId, stream } = options;
|
||||
const { displayId, streamId } = options;
|
||||
|
||||
if (!stream || !stream.active || stream.getVideoTracks().length !== 1) {
|
||||
callback({ type: 'error', reason: 'bad stream' });
|
||||
if (streamId && typeof streamId !== 'string') {
|
||||
callback({ type: 'error', reason: 'bad streamId' });
|
||||
return;
|
||||
}
|
||||
|
||||
if (displayId && typeof displayId !== 'string') {
|
||||
callback({ type: 'error', reason: 'bad displayId' });
|
||||
return;
|
||||
}
|
||||
|
||||
const destroy = () => {
|
||||
throttledCloseScreenShareIndicator(stream.id);
|
||||
stream.removeEventListener('inactive', destroy);
|
||||
};
|
||||
|
||||
stream.addEventListener('inactive', destroy);
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
local.screenSharingIndicatorCallback = callback;
|
||||
ipcRenderer.send(apiName.symphonyApi, {
|
||||
cmd: apiCmds.openScreenSharingIndicator,
|
||||
displayId,
|
||||
id: ++nextIndicatorId,
|
||||
streamId: stream.id,
|
||||
streamId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user