public get()

in packages/calling-stateful-client/src/CallDeclarativeCommon.ts [146:190]


  public get<P extends keyof TeamsCaptions>(target: TeamsCaptions, prop: P): any {
    switch (prop) {
      case 'startCaptions':
        return this._context.withAsyncErrorTeedToState(async (...args: Parameters<TeamsCaptions['startCaptions']>) => {
          this._context.setStartCaptionsInProgress(this._call.id, true);
          try {
            const ret = await target.startCaptions(...args);
            this._context.setSelectedSpokenLanguage(this._call.id, args[0]?.spokenLanguage ?? 'en-us');
            return ret;
          } catch (e) {
            this._context.setStartCaptionsInProgress(this._call.id, false);
            throw e;
          }
        }, 'Call.feature');
        break;
      case 'stopCaptions':
        return this._context.withAsyncErrorTeedToState(async (...args: Parameters<TeamsCaptions['stopCaptions']>) => {
          const ret = await target.stopCaptions(...args);
          this._context.setIsCaptionActive(this._call.id, false);
          this._context.setStartCaptionsInProgress(this._call.id, false);
          this._context.clearCaptions(this._call.id);
          return ret;
        }, 'Call.feature');
      case 'setSpokenLanguage':
        return this._context.withAsyncErrorTeedToState(
          async (...args: Parameters<TeamsCaptions['setSpokenLanguage']>) => {
            const ret = await target.setSpokenLanguage(...args);
            this._context.setSelectedSpokenLanguage(this._call.id, args[0]);
            return ret;
          },
          'Call.feature'
        );
      case 'setCaptionLanguage':
        return this._context.withAsyncErrorTeedToState(
          async (...args: Parameters<TeamsCaptions['setCaptionLanguage']>) => {
            const ret = await target.setCaptionLanguage(...args);
            this._context.setSelectedCaptionLanguage(this._call.id, args[0]);
            return ret;
          },
          'Call.feature'
        );
      default:
        return Reflect.get(target, prop);
    }
  }