communication-react-19
Version:
React library for building modern communication user experiences utilizing Azure Communication Services (React 19 compatible fork)
36 lines • 1.78 kB
JavaScript
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/* @conditional-compile-remove(local-recording-notification) */
/**
* @private
*/
export class LocalRecordingSubscriber {
constructor(callIdRef, context, recording) {
this.subscribe = () => {
this._recording.on('isLocalRecordingActiveChanged', this.isAvailableChanged);
this._recording.on('localRecordingsUpdated', this.isRecordingsUpdated);
};
this.unsubscribe = () => {
this._recording.off('isLocalRecordingActiveChanged', this.isAvailableChanged);
this._recording.off('localRecordingsUpdated', this.isRecordingsUpdated);
};
this.isAvailableChanged = () => {
this._context.setCallLocalRecordingActive(this._callIdRef.callId, this._recording.isRecordingActive);
};
this.isRecordingsUpdated = (data) => {
this._context.setCallLocalRecordingInfos(this._callIdRef.callId, this._recording.recordings, data.removed);
};
this._callIdRef = callIdRef;
this._context = context;
this._recording = recording;
// If recording as already started when we joined the call, make sure it is reflected in state as there may not
// be an event for it.
if (this._recording.isRecordingActive) {
this._context.setCallLocalRecordingActive(this._callIdRef.callId, this._recording.isRecordingActive);
// recordings getter only returns a list of active recordings, so we can set the list of recordings here
this._context.setCallLocalRecordingInfos(this._callIdRef.callId, this._recording.recordings, []);
}
this.subscribe();
}
}
//# sourceMappingURL=LocalRecordingSubscriber.js.map