Преглед на файлове

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

j8
hristoterezov преди 8 години
родител
ревизия
09c8e14465
променени са 2 файла, в които са добавени 63 реда и са изтрити 5 реда
  1. 5
    1
      lang/main.json
  2. 58
    4
      modules/UI/videolayout/RemoteVideo.js

+ 5
- 1
lang/main.json Целия файл

@@ -283,6 +283,7 @@
283 283
         "stopLiveStreaming": "Stop live streaming",
284 284
         "stopRecording": "Stop recording",
285 285
         "doNotShowWarningAgain": "Don't show this warning again",
286
+        "doNotShowMessageAgain": "Don't show this message again",
286 287
         "permissionDenied": "Permission Denied",
287 288
         "screenSharingPermissionDeniedError": "You have not granted permission to share your screen.",
288 289
         "micErrorPresent": "There was an error connecting to your microphone.",
@@ -300,7 +301,10 @@
300 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 302
         "goToStore": "Go to the webstore",
302 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 309
     "email":
306 310
     {

+ 58
- 4
modules/UI/videolayout/RemoteVideo.js Целия файл

@@ -7,6 +7,11 @@ import UIUtils from "../util/UIUtil";
7 7
 import UIEvents from '../../../service/UI/UIEvents';
8 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 16
  * Creates new instance of the <tt>RemoteVideo</tt>.
12 17
  * @param user {JitsiParticipant} the user for whom remote video instance will
@@ -130,15 +135,21 @@ RemoteVideo.prototype._generatePopupContent = function () {
130 135
     }
131 136
 
132 137
     // Delegate event to the document.
133
-    $(document).on("click", "#mutelink_" + this.id, function(){
134
-
138
+    $(document).on("click", "#mutelink_" + this.id, () => {
135 139
         if (this.isAudioMuted)
136 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 151
         this.popover.forceHide();
141
-    }.bind(this));
152
+    });
142 153
 
143 154
     muteMenuItem.appendChild(muteLinkItem);
144 155
     popupmenuElement.appendChild(muteMenuItem);
@@ -570,4 +581,47 @@ RemoteVideo.createContainer = function (spanId) {
570 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 627
 export default RemoteVideo;

Loading…
Отказ
Запис