diff --git a/web/app/widget-wrappers/jitsi/jitsi.component.ts b/web/app/widget-wrappers/jitsi/jitsi.component.ts index 72318cc..4de03ed 100644 --- a/web/app/widget-wrappers/jitsi/jitsi.component.ts +++ b/web/app/widget-wrappers/jitsi/jitsi.component.ts @@ -46,10 +46,38 @@ export class JitsiWidgetWrapperComponent extends CapableWidget implements OnInit $.getScript(widget.options.scriptUrl); }); this.jitsiApiSubscription = ScalarWidgetApi.requestReceived.subscribe(request => { - if (request.action === "audioMuteToggle" && this.isJoined) { - this.jitsiApiObj.executeCommand('toggleAudio'); - ScalarWidgetApi.replyAcknowledge(request); + if (!this.isJoined) { + return; } + + switch (request.action) { + case "audioToggle": + this.jitsiApiObj.executeCommand('toggleAudio'); + break; + case "audioMute": + this.jitsiApiObj.isAudioMuted().then((muted) => { + // Toggle audio if Jitsi is not currently muted + if (!muted) { + this.jitsiApiObj.executeCommand('toggleAudio'); + } + }); + break; + case "audioUnmute": + this.jitsiApiObj.isAudioMuted().then((muted) => { + // Toggle audio if Jitsi is currently muted + if (muted) { + this.jitsiApiObj.executeCommand('toggleAudio'); + } + }); + break; + default: + // Unknown command sent + return; + } + + // TODO: Travis, should this fire even if we didn't get a command we're + // handling? + ScalarWidgetApi.replyAcknowledge(request); }); }