Browse Source

Got rid of direct usage of room locker

master
Ilya Daynatovich 9 years ago
parent
commit
d4df6f2dda

+ 0
- 31
modules/UI/invite/AskForPassword.js View File

@@ -1,31 +0,0 @@
1
-/* global APP, $ */
2
-
3
-import UIUtil from '../util/UIUtil';
4
-
5
-/**
6
- * Show dialog which asks for required conference password.
7
- * @returns {Promise<string>} password or nothing if user canceled
8
- */
9
-export default function askForPassword () {
10
-    let titleKey = "dialog.passwordRequired";
11
-    let msgString = `
12
-        <input name="lockKey" type="text"
13
-               data-i18n="[placeholder]dialog.password"
14
-               autofocus>`;
15
-    return new Promise(function (resolve, reject) {
16
-        APP.UI.messageHandler.openTwoButtonDialog({
17
-            titleKey,
18
-            msgString,
19
-            leftButtonKey: "dialog.Ok",
20
-            submitFunction: $.noop,
21
-            closeFunction: function (e, v, m, f) {
22
-                if (v && f.lockKey) {
23
-                    resolve(UIUtil.escapeHtml(f.lockKey));
24
-                } else {
25
-                    reject(APP.UI.messageHandler.CANCEL);
26
-                }
27
-            },
28
-            focus: ':input:first'
29
-        });
30
-    });
31
-}

+ 13
- 11
modules/UI/invite/Invite.js View File

@@ -32,7 +32,7 @@ class Invite {
32 32
                 error);
33 33
 
34 34
             if (!locked) {
35
-                this.roomLocker.resetPassword();
35
+                this.getRoomLocker().resetPassword();
36 36
             }
37 37
 
38 38
             this.setLockedFromElsewhere(locked);
@@ -56,9 +56,10 @@ class Invite {
56 56
 
57 57
         APP.UI.addListener( UIEvents.PASSWORD_REQUIRED,
58 58
             () => {
59
+                let roomLocker = this.getRoomLocker();
59 60
                 this.setLockedFromElsewhere(true);
60
-                this.roomLocker.requirePassword().then(() => {
61
-                    let pass = this.roomLocker.password;
61
+                roomLocker.requirePassword().then(() => {
62
+                    let pass = roomLocker.password;
62 63
                     // we received that password is required, but user is trying
63 64
                     // anyway to login without a password, mark room as not
64 65
                     // locked in case he succeeds (maybe someone removed the
@@ -67,7 +68,7 @@ class Invite {
67 68
                     // will be marked as locked.
68 69
                     if (!pass)
69 70
                         this.setLockedFromElsewhere(false);
70
-                    this.conference.join(this.roomLocker.password);
71
+                    this.conference.join(roomLocker.password);
71 72
                 });
72 73
             });
73 74
     }
@@ -129,7 +130,7 @@ class Invite {
129 130
      * @returns {String} password
130 131
      */
131 132
     getPassword() {
132
-        return this.roomLocker.password;
133
+        return this.getRoomLocker().password;
133 134
     }
134 135
 
135 136
     /**
@@ -149,7 +150,7 @@ class Invite {
149 150
      */
150 151
     setRoomUnlocked() {
151 152
         if (this.isModerator) {
152
-            this.roomLocker.lock().then(() => {
153
+            this.getRoomLocker().lock().then(() => {
153 154
                 APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK);
154 155
                 this.updateView();
155 156
             });
@@ -164,8 +165,8 @@ class Invite {
164 165
      */
165 166
     setRoomLocked(newPass) {
166 167
         let isModerator = this.isModerator;
167
-        if (isModerator && (newPass || !this.roomLocker.isLocked)) {
168
-            this.roomLocker.lock(newPass).then(() => {
168
+        if (isModerator && (newPass || !this.getRoomLocker().isLocked)) {
169
+            this.getRoomLocker().lock(newPass).then(() => {
169 170
                 APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK);
170 171
                 this.updateView();
171 172
             });
@@ -187,7 +188,7 @@ class Invite {
187 188
      * @returns {Boolean} isLocked
188 189
      */
189 190
     isLocked() {
190
-        return this.roomLocker.isLocked;
191
+        return this.getRoomLocker().isLocked;
191 192
     }
192 193
 
193 194
     /**
@@ -195,9 +196,10 @@ class Invite {
195 196
      * @param isLocked
196 197
      */
197 198
     setLockedFromElsewhere(isLocked) {
198
-        let oldLockState = this.roomLocker.isLocked;
199
+        let roomLocker = this.getRoomLocker();
200
+        let oldLockState = roomLocker.isLocked;
199 201
         if (oldLockState !== isLocked) {
200
-            this.roomLocker.lockedElsewhere = isLocked;
202
+            roomLocker.lockedElsewhere = isLocked;
201 203
             APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK);
202 204
             this.updateView();
203 205
         }

+ 3
- 6
modules/UI/invite/RequirePasswordDialog.js View File

@@ -23,19 +23,16 @@ export default class RequirePasswordDialog {
23 23
     }
24 24
 
25 25
     _getBodyMessage() {
26
-        let passMsg = APP.translation.translateString("dialog.password");
27
-        let label = APP.translation.translateString(this.labelKey);
28
-        let error = APP.translation.translateString(this.errorKey);
29 26
         return (
30 27
             `<div class="input-control">
31 28
                 <label class="input-control__label"
32
-                       data-i18n="${this.labelKey}">${label}</label>
29
+                       data-i18n="${this.labelKey}"></label>
33 30
                 <input class="input-control__input" name="lockKey" type="text"
34 31
                    data-i18n="[placeholder]dialog.password"
35
-                   placeholder="${passMsg}" autofocus id="${this.inputId}">
32
+                   autofocus id="${this.inputId}">
36 33
                 <p class="input-control__hint input-control__hint_error hide"
37 34
                    id="${this.errorId}"
38
-                   data-i18n="${this.errorKey}">${error}</p>
35
+                   data-i18n="${this.errorKey}"></p>
39 36
             </div>`
40 37
         );
41 38
     }

Loading…
Cancel
Save