From d4df6f2ddadc03d63fdcc6d6cb4093b08d4f4f7f Mon Sep 17 00:00:00 2001 From: Ilya Daynatovich Date: Fri, 21 Oct 2016 18:03:25 +0300 Subject: [PATCH] Got rid of direct usage of room locker --- modules/UI/invite/AskForPassword.js | 31 ---------------------- modules/UI/invite/Invite.js | 24 +++++++++-------- modules/UI/invite/RequirePasswordDialog.js | 9 +++---- 3 files changed, 16 insertions(+), 48 deletions(-) delete mode 100644 modules/UI/invite/AskForPassword.js diff --git a/modules/UI/invite/AskForPassword.js b/modules/UI/invite/AskForPassword.js deleted file mode 100644 index 77a27ddf4..000000000 --- a/modules/UI/invite/AskForPassword.js +++ /dev/null @@ -1,31 +0,0 @@ -/* global APP, $ */ - -import UIUtil from '../util/UIUtil'; - -/** - * Show dialog which asks for required conference password. - * @returns {Promise} password or nothing if user canceled - */ -export default function askForPassword () { - let titleKey = "dialog.passwordRequired"; - let msgString = ` - `; - return new Promise(function (resolve, reject) { - APP.UI.messageHandler.openTwoButtonDialog({ - titleKey, - msgString, - leftButtonKey: "dialog.Ok", - submitFunction: $.noop, - closeFunction: function (e, v, m, f) { - if (v && f.lockKey) { - resolve(UIUtil.escapeHtml(f.lockKey)); - } else { - reject(APP.UI.messageHandler.CANCEL); - } - }, - focus: ':input:first' - }); - }); -} \ No newline at end of file diff --git a/modules/UI/invite/Invite.js b/modules/UI/invite/Invite.js index 737ed673b..7cc821e01 100644 --- a/modules/UI/invite/Invite.js +++ b/modules/UI/invite/Invite.js @@ -32,7 +32,7 @@ class Invite { error); if (!locked) { - this.roomLocker.resetPassword(); + this.getRoomLocker().resetPassword(); } this.setLockedFromElsewhere(locked); @@ -56,9 +56,10 @@ class Invite { APP.UI.addListener( UIEvents.PASSWORD_REQUIRED, () => { + let roomLocker = this.getRoomLocker(); this.setLockedFromElsewhere(true); - this.roomLocker.requirePassword().then(() => { - let pass = this.roomLocker.password; + roomLocker.requirePassword().then(() => { + let pass = roomLocker.password; // we received that password is required, but user is trying // anyway to login without a password, mark room as not // locked in case he succeeds (maybe someone removed the @@ -67,7 +68,7 @@ class Invite { // will be marked as locked. if (!pass) this.setLockedFromElsewhere(false); - this.conference.join(this.roomLocker.password); + this.conference.join(roomLocker.password); }); }); } @@ -129,7 +130,7 @@ class Invite { * @returns {String} password */ getPassword() { - return this.roomLocker.password; + return this.getRoomLocker().password; } /** @@ -149,7 +150,7 @@ class Invite { */ setRoomUnlocked() { if (this.isModerator) { - this.roomLocker.lock().then(() => { + this.getRoomLocker().lock().then(() => { APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK); this.updateView(); }); @@ -164,8 +165,8 @@ class Invite { */ setRoomLocked(newPass) { let isModerator = this.isModerator; - if (isModerator && (newPass || !this.roomLocker.isLocked)) { - this.roomLocker.lock(newPass).then(() => { + if (isModerator && (newPass || !this.getRoomLocker().isLocked)) { + this.getRoomLocker().lock(newPass).then(() => { APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK); this.updateView(); }); @@ -187,7 +188,7 @@ class Invite { * @returns {Boolean} isLocked */ isLocked() { - return this.roomLocker.isLocked; + return this.getRoomLocker().isLocked; } /** @@ -195,9 +196,10 @@ class Invite { * @param isLocked */ setLockedFromElsewhere(isLocked) { - let oldLockState = this.roomLocker.isLocked; + let roomLocker = this.getRoomLocker(); + let oldLockState = roomLocker.isLocked; if (oldLockState !== isLocked) { - this.roomLocker.lockedElsewhere = isLocked; + roomLocker.lockedElsewhere = isLocked; APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK); this.updateView(); } diff --git a/modules/UI/invite/RequirePasswordDialog.js b/modules/UI/invite/RequirePasswordDialog.js index a5e80cd48..d8a71cd34 100644 --- a/modules/UI/invite/RequirePasswordDialog.js +++ b/modules/UI/invite/RequirePasswordDialog.js @@ -23,19 +23,16 @@ export default class RequirePasswordDialog { } _getBodyMessage() { - let passMsg = APP.translation.translateString("dialog.password"); - let label = APP.translation.translateString(this.labelKey); - let error = APP.translation.translateString(this.errorKey); return ( `
+ data-i18n="${this.labelKey}"> + autofocus id="${this.inputId}">

${error}

+ data-i18n="${this.errorKey}">

` ); }