Procházet zdrojové kódy

Merge pull request #1757 from jitsi/rc_dialog_to_notification

fix(remotecontrol): Replace info dialogs with notifications.
master
virtuacoplenny před 8 roky
rodič
revize
37328b3995

+ 2
- 2
css/_toastr.scss Zobrazit soubor

@@ -12,7 +12,7 @@
12 12
  */
13 13
 
14 14
 .toast-title,
15
-.toast-message .nickname {
15
+.toast-message .title {
16 16
   font-weight: bold;
17 17
   margin: 0 0 3px;
18 18
   @include text-truncate;
@@ -104,4 +104,4 @@
104 104
 #toast-container .toast {
105 105
   width: $notificationWidth;
106 106
   margin: 0 0 8px;
107
-}
107
+}

+ 11
- 11
modules/UI/UI.js Zobrazit soubor

@@ -192,8 +192,8 @@ UI.showLocalConnectionInterrupted = function (isInterrupted) {
192 192
 UI.setRaisedHandStatus = (participant, raisedHandStatus) => {
193 193
     VideoLayout.setRaisedHandStatus(participant.getId(), raisedHandStatus);
194 194
     if (raisedHandStatus) {
195
-        messageHandler.notify(participant.getDisplayName(), 'notify.somebody',
196
-                          'connected', 'notify.raisedHand');
195
+        messageHandler.participantNotification(participant.getDisplayName(),
196
+            'notify.somebody', 'connected', 'notify.raisedHand');
197 197
     }
198 198
 };
199 199
 
@@ -488,7 +488,7 @@ UI.addUser = function (user) {
488 488
     if (UI.ContactList)
489 489
         UI.ContactList.addContact(id);
490 490
 
491
-    messageHandler.notify(
491
+    messageHandler.participantNotification(
492 492
         displayName,'notify.somebody', 'connected', 'notify.connected'
493 493
     );
494 494
 
@@ -516,7 +516,7 @@ UI.removeUser = function (id, displayName) {
516 516
     if (UI.ContactList)
517 517
         UI.ContactList.removeContact(id);
518 518
 
519
-    messageHandler.notify(
519
+    messageHandler.participantNotification(
520 520
         displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
521 521
     );
522 522
 
@@ -552,8 +552,8 @@ UI.updateLocalRole = isModerator => {
552 552
 
553 553
     if (isModerator) {
554 554
         if (!interfaceConfig.DISABLE_FOCUS_INDICATOR)
555
-            messageHandler
556
-                .notify(null, "notify.me", 'connected', "notify.moderator");
555
+            messageHandler.participantNotification(
556
+                null, "notify.me", 'connected', "notify.moderator");
557 557
 
558 558
         Recording.checkAutoRecord();
559 559
     }
@@ -575,14 +575,14 @@ UI.updateUserRole = user => {
575 575
 
576 576
     var displayName = user.getDisplayName();
577 577
     if (displayName) {
578
-        messageHandler.notify(
578
+        messageHandler.participantNotification(
579 579
             displayName, 'notify.somebody',
580 580
             'connected', 'notify.grantedTo', {
581 581
                 to: UIUtil.escapeHtml(displayName)
582 582
             }
583 583
         );
584 584
     } else {
585
-        messageHandler.notify(
585
+        messageHandler.participantNotification(
586 586
             '', 'notify.somebody',
587 587
             'connected', 'notify.grantedToUnknown');
588 588
     }
@@ -596,7 +596,7 @@ UI.updateUserRole = user => {
596 596
  */
597 597
 UI.updateUserStatus = (user, status) => {
598 598
     let displayName = user.getDisplayName();
599
-    messageHandler.notify(
599
+    messageHandler.participantNotification(
600 600
         displayName, '', 'connected', "dialOut.statusMessage",
601 601
         {
602 602
             status: UIUtil.escapeHtml(status)
@@ -864,7 +864,7 @@ UI.notifyMaxUsersLimitReached = function () {
864 864
  * Notify user that he was automatically muted when joned the conference.
865 865
  */
866 866
 UI.notifyInitiallyMuted = function () {
867
-    messageHandler.notify(
867
+    messageHandler.participantNotification(
868 868
         null,
869 869
         "notify.mutedTitle",
870 870
         "connected",
@@ -1069,7 +1069,7 @@ UI.notifyInternalError = function () {
1069 1069
 };
1070 1070
 
1071 1071
 UI.notifyFocusDisconnected = function (focus, retrySec) {
1072
-    messageHandler.notify(
1072
+    messageHandler.participantNotification(
1073 1073
         null, "notify.focus",
1074 1074
         'disconnected', "notify.focusFail",
1075 1075
         {component: focus, ms: retrySec}

+ 33
- 4
modules/UI/util/MessageHandler.js Zobrazit soubor

@@ -439,7 +439,7 @@ var messageHandler = {
439 439
     },
440 440
 
441 441
     /**
442
-     * Displays a notification.
442
+     * Displays a notification about participant action.
443 443
      * @param displayName the display name of the participant that is
444 444
      * associated with the notification.
445 445
      * @param displayNameKey the key from the language file for the display
@@ -450,14 +450,14 @@ var messageHandler = {
450 450
      * @param messageArguments object with the arguments for the message.
451 451
      * @param options passed to toastr (e.g. timeOut)
452 452
      */
453
-    notify: function(displayName, displayNameKey, cls, messageKey,
454
-                     messageArguments, options) {
453
+    participantNotification: function(displayName, displayNameKey, cls,
454
+                    messageKey, messageArguments, options) {
455 455
 
456 456
         // If we're in ringing state we skip all toaster notifications.
457 457
         if(!notificationsEnabled || APP.UI.isOverlayVisible())
458 458
             return;
459 459
 
460
-        var displayNameSpan = '<span class="nickname" ';
460
+        var displayNameSpan = '<span class="title" ';
461 461
         if (displayName) {
462 462
             displayNameSpan += ">" + UIUtil.escapeHtml(displayName);
463 463
         } else {
@@ -475,6 +475,35 @@ var messageHandler = {
475 475
         return element;
476 476
     },
477 477
 
478
+    /**
479
+     * Displays a notification.
480
+     *
481
+     * @param {string} titleKey - The key from the language file for the title
482
+     * of the notification.
483
+     * @param {string} messageKey - The key from the language file for the text
484
+     * of the message.
485
+     * @param {Object} messageArguments - The arguments for the message
486
+     * translation.
487
+     * @returns {void}
488
+     */
489
+    notify: function(titleKey, messageKey, messageArguments) {
490
+
491
+        // If we're in ringing state we skip all toaster notifications.
492
+        if(!notificationsEnabled || APP.UI.isOverlayVisible())
493
+            return;
494
+
495
+        const options = messageArguments
496
+            ? `data-i18n-options='${JSON.stringify(messageArguments)}'` : "";
497
+        let element = toastr.info(`
498
+            <span class="title" data-i18n="${titleKey}"></span>
499
+            <br>
500
+            <span data-i18n="${messageKey}" ${options}></span>
501
+            `
502
+        );
503
+        APP.translation.translateElement(element);
504
+        return element;
505
+    },
506
+
478 507
     /**
479 508
      * Removes the toaster.
480 509
      * @param toasterElement

+ 2
- 2
modules/UI/videolayout/RemoteVideo.js Zobrazit soubor

@@ -248,7 +248,7 @@ RemoteVideo.prototype._requestRemoteControlPermissions = function () {
248 248
             return;
249 249
         }
250 250
         this.updateRemoteVideoMenu(this.isAudioMuted, true);
251
-        APP.UI.messageHandler.openMessageDialog(
251
+        APP.UI.messageHandler.notify(
252 252
             "dialog.remoteControlTitle",
253 253
             (result === false) ? "dialog.remoteControlDeniedMessage"
254 254
                 : "dialog.remoteControlAllowedMessage",
@@ -265,7 +265,7 @@ RemoteVideo.prototype._requestRemoteControlPermissions = function () {
265 265
     }, error => {
266 266
         logger.error(error);
267 267
         this.updateRemoteVideoMenu(this.isAudioMuted, true);
268
-        APP.UI.messageHandler.openMessageDialog(
268
+        APP.UI.messageHandler.notify(
269 269
             "dialog.remoteControlTitle",
270 270
             "dialog.remoteControlErrorMessage",
271 271
             {user: this.user.getDisplayName()

+ 1
- 1
modules/remotecontrol/Controller.js Zobrazit soubor

@@ -312,7 +312,7 @@ export default class Controller extends RemoteControlParticipant {
312 312
         this.pause();
313 313
         this._controlledParticipant = null;
314 314
         this._area = undefined;
315
-        APP.UI.messageHandler.openMessageDialog(
315
+        APP.UI.messageHandler.notify(
316 316
             'dialog.remoteControlTitle',
317 317
             'dialog.remoteControlStopMessage'
318 318
         );

+ 6
- 6
modules/remotecontrol/Receiver.js Zobrazit soubor

@@ -109,11 +109,11 @@ export default class Receiver extends RemoteControlParticipant {
109 109
      * displays dialog for informing the user that remote control session
110 110
      * ended.
111 111
      *
112
-     * @param {boolean} [dontShowDialog] - If true the dialog won't be
113
-     * displayed.
112
+     * @param {boolean} [dontNotify] - If true - a notification about stopping
113
+     * the remote control won't be displayed.
114 114
      * @returns {void}
115 115
      */
116
-    _stop(dontShowDialog: boolean = false) {
116
+    _stop(dontNotify: boolean = false) {
117 117
         if (!this._controller) {
118 118
             return;
119 119
         }
@@ -125,8 +125,8 @@ export default class Receiver extends RemoteControlParticipant {
125 125
             name: REMOTE_CONTROL_MESSAGE_NAME,
126 126
             type: EVENTS.stop
127 127
         });
128
-        if (!dontShowDialog) {
129
-            APP.UI.messageHandler.openMessageDialog(
128
+        if (!dontNotify) {
129
+            APP.UI.messageHandler.notify(
130 130
                 'dialog.remoteControlTitle',
131 131
                 'dialog.remoteControlStopMessage'
132 132
             );
@@ -241,7 +241,7 @@ export default class Receiver extends RemoteControlParticipant {
241 241
                     action: PERMISSIONS_ACTIONS.error
242 242
                 });
243 243
 
244
-                APP.UI.messageHandler.openMessageDialog(
244
+                APP.UI.messageHandler.notify(
245 245
                     'dialog.remoteControlTitle',
246 246
                     'dialog.startRemoteControlErrorMessage'
247 247
                 );

Načítá se…
Zrušit
Uložit