Browse Source

feat(Mute_Participant): Implement warning dialog for muting remote participant

master
hristoterezov 8 years ago
parent
commit
09c8e14465
2 changed files with 63 additions and 5 deletions
  1. 5
    1
      lang/main.json
  2. 58
    4
      modules/UI/videolayout/RemoteVideo.js

+ 5
- 1
lang/main.json View File

283
         "stopLiveStreaming": "Stop live streaming",
283
         "stopLiveStreaming": "Stop live streaming",
284
         "stopRecording": "Stop recording",
284
         "stopRecording": "Stop recording",
285
         "doNotShowWarningAgain": "Don't show this warning again",
285
         "doNotShowWarningAgain": "Don't show this warning again",
286
+        "doNotShowMessageAgain": "Don't show this message again",
286
         "permissionDenied": "Permission Denied",
287
         "permissionDenied": "Permission Denied",
287
         "screenSharingPermissionDeniedError": "You have not granted permission to share your screen.",
288
         "screenSharingPermissionDeniedError": "You have not granted permission to share your screen.",
288
         "micErrorPresent": "There was an error connecting to your microphone.",
289
         "micErrorPresent": "There was an error connecting to your microphone.",
300
         "cameraNotSendingData": "We are unable to access your camera. Please check if another application is using this device, select another device from the settings menu or try to restart the application.",
301
         "cameraNotSendingData": "We are unable to access your camera. Please check if another application is using this device, select another device from the settings menu or try to restart the application.",
301
         "goToStore": "Go to the webstore",
302
         "goToStore": "Go to the webstore",
302
         "externalInstallationTitle": "Extension required",
303
         "externalInstallationTitle": "Extension required",
303
-        "externalInstallationMsg": "You need to install our desktop sharing extension."
304
+        "externalInstallationMsg": "You need to install our desktop sharing extension.",
305
+        "muteParticipantTitle": "Mute this participant?",
306
+        "muteParticipantBody": "You won't be able to unmute them, but they can unmute themselves at any time.",
307
+        "muteParticipantButton": "Mute"
304
     },
308
     },
305
     "email":
309
     "email":
306
     {
310
     {

+ 58
- 4
modules/UI/videolayout/RemoteVideo.js View File

7
 import UIEvents from '../../../service/UI/UIEvents';
7
 import UIEvents from '../../../service/UI/UIEvents';
8
 import JitsiPopover from "../util/JitsiPopover";
8
 import JitsiPopover from "../util/JitsiPopover";
9
 
9
 
10
+const MUTED_DIALOG_BUTTON_VALUES = {
11
+    cancel: 0,
12
+    muted: 1
13
+};
14
+
10
 /**
15
 /**
11
  * Creates new instance of the <tt>RemoteVideo</tt>.
16
  * Creates new instance of the <tt>RemoteVideo</tt>.
12
  * @param user {JitsiParticipant} the user for whom remote video instance will
17
  * @param user {JitsiParticipant} the user for whom remote video instance will
130
     }
135
     }
131
 
136
 
132
     // Delegate event to the document.
137
     // Delegate event to the document.
133
-    $(document).on("click", "#mutelink_" + this.id, function(){
134
-
138
+    $(document).on("click", "#mutelink_" + this.id, () => {
135
         if (this.isAudioMuted)
139
         if (this.isAudioMuted)
136
             return;
140
             return;
137
 
141
 
138
-        this.emitter.emit(UIEvents.REMOTE_AUDIO_MUTED, this.id);
142
+        RemoteVideo.showMuteParticipantDialog().then(reason => {
143
+            if(reason === MUTED_DIALOG_BUTTON_VALUES.muted) {
144
+                this.emitter.emit(UIEvents.REMOTE_AUDIO_MUTED, this.id);
145
+            }
146
+        }).catch(e => {
147
+            //currently shouldn't be called
148
+            console.error(e);
149
+        });
139
 
150
 
140
         this.popover.forceHide();
151
         this.popover.forceHide();
141
-    }.bind(this));
152
+    });
142
 
153
 
143
     muteMenuItem.appendChild(muteLinkItem);
154
     muteMenuItem.appendChild(muteLinkItem);
144
     popupmenuElement.appendChild(muteMenuItem);
155
     popupmenuElement.appendChild(muteMenuItem);
570
     return remotes.appendChild(container);
581
     return remotes.appendChild(container);
571
 };
582
 };
572
 
583
 
584
+/**
585
+ * Shows 2 button dialog for confirmation from the user for muting remote
586
+ * participant.
587
+ */
588
+RemoteVideo.showMuteParticipantDialog = function () {
589
+    //FIXME: don't show again checkbox is implemented very dirty. we should add
590
+    // this functionality to MessageHandler class.
591
+    if (window.localStorage
592
+        && window.localStorage.getItem(
593
+            "dontShowMuteParticipantDialog") === "true") {
594
+        return Promise.resolve(MUTED_DIALOG_BUTTON_VALUES.muted);
595
+    }
596
+    let msgString =
597
+        `<div data-i18n="dialog.muteParticipantBody"></div>
598
+        <br />
599
+        <label>
600
+            <input type='checkbox' checked id='doNotShowMessageAgain' />
601
+            <span data-i18n='dialog.doNotShowMessageAgain'></span>
602
+        </label>`;
603
+    return new Promise(resolve => {
604
+        APP.UI.messageHandler.openTwoButtonDialog({
605
+            titleKey : "dialog.muteParticipantTitle",
606
+            msgString,
607
+            leftButtonKey: 'dialog.muteParticipantButton',
608
+            submitFunction: () => {
609
+                if(window.localStorage) {
610
+                    let form  = $.prompt.getPrompt();
611
+                    if (form) {
612
+                        let input = form.find("#doNotShowMessageAgain");
613
+                        if (input.length) {
614
+                            window.localStorage.setItem(
615
+                                "dontShowMuteParticipantDialog",
616
+                                input.prop("checked"));
617
+                        }
618
+                    }
619
+                }
620
+                resolve(MUTED_DIALOG_BUTTON_VALUES.muted);
621
+            },
622
+            closeFunction: () => resolve(MUTED_DIALOG_BUTTON_VALUES.cancel)
623
+        });
624
+    });
625
+};
626
+
573
 export default RemoteVideo;
627
 export default RemoteVideo;

Loading…
Cancel
Save