From e32a910f5093546f2efcb1af8883c61eeaebc137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Sun, 2 Dec 2018 18:11:06 +0100 Subject: [PATCH] Base message on number of users and additional message on type of room MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before, the message explicitly mentioned the other user and her avatar was used as the icon only for one to one rooms. Now that will be done for any type of room if there is only another registered user and no guests in that room. In a similar way, the additional message hinting how to invite other users now is always shown in group and public rooms, no matter how many users are currently in the room; this is the same as before for public rooms, although it was changed for consistency for group rooms, as in that case the message was shown only when there were no other participants in the room. Signed-off-by: Daniel Calviño Sánchez --- js/app.js | 70 +++++++++++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/js/app.js b/js/app.js index 34f7999d1..0e29d5db1 100644 --- a/js/app.js +++ b/js/app.js @@ -634,51 +634,45 @@ var url = ''; var participants = this.activeRoom.get('participants'); + var numberOfParticipants = Object.keys(participants).length; - switch(this.activeRoom.get('type')) { - case OCA.SpreedMe.app.ROOM_TYPE_ONE_TO_ONE: - var participantId = '', - participantName = ''; + if (this.activeRoom.get('type') === OCA.SpreedMe.app.ROOM_TYPE_PUBLIC) { + icon = 'icon-public'; + } else { + icon = 'icon-contacts-dark'; + } - _.each(participants, function(data, userId) { - if (OC.getCurrentUser().uid !== userId) { - participantId = userId; - participantName = data.name; - } - }); + if (numberOfParticipants === 1 && this.activeRoom.get('numGuests') === 0) { + message = t('spreed', 'No other people in this call'); + } else if (numberOfParticipants === 2 && this.activeRoom.get('numGuests') === 0) { + var participantId = '', + participantName = ''; - icon = { userId: participantId, displayName: participantName}; - - message = t('spreed', 'Waiting for {participantName} to join the call …', {participantName: participantName}); - break; - case OCA.SpreedMe.app.ROOM_TYPE_PUBLIC: - case OCA.SpreedMe.app.ROOM_TYPE_GROUP: - if (this.activeRoom.get('type') === OCA.SpreedMe.app.ROOM_TYPE_PUBLIC) { - icon = 'icon-public'; - } else { - icon = 'icon-contacts-dark'; + _.each(participants, function(data, userId) { + if (OC.getCurrentUser().uid !== userId) { + participantId = userId; + participantName = data.name; } + }); - message = t('spreed', 'Waiting for others to join the call …'); + icon = { userId: participantId, displayName: participantName}; - if (OC.getCurrentUser().uid !== null && Object.keys(participants).length === 1) { - message = t('spreed', 'No other people in this call'); - if (this.activeRoom.get('participantType') === OCA.SpreedMe.app.OWNER || this.activeRoom.get('participantType') === OCA.SpreedMe.app.MODERATOR) { - messageAdditional = t('spreed', 'You can invite others in the participant tab of the sidebar'); - } - } + message = t('spreed', 'Waiting for {participantName} to join the call …', {participantName: participantName}); + } else { + message = t('spreed', 'Waiting for others to join the call …'); + } - if (this.activeRoom.get('type') === OCA.SpreedMe.app.ROOM_TYPE_PUBLIC) { - messageAdditional = t('spreed', 'Share this link to invite others!'); - if (this.activeRoom.get('participantType') === OCA.SpreedMe.app.OWNER || this.activeRoom.get('participantType') === OCA.SpreedMe.app.MODERATOR) { - messageAdditional = t('spreed', 'You can invite others in the participant tab of the sidebar or share this link to invite others!'); - } - url = window.location.protocol + '//' + window.location.host + OC.generateUrl('/call/' + this.activeRoom.get('token')); - } - break; - default: - console.log("Unknown room type", this.activeRoom.get('type')); - return; + if (this.activeRoom.get('type') === OCA.SpreedMe.app.ROOM_TYPE_GROUP && + (this.activeRoom.get('participantType') === OCA.SpreedMe.app.OWNER || this.activeRoom.get('participantType') === OCA.SpreedMe.app.MODERATOR)) { + messageAdditional = t('spreed', 'You can invite others in the participant tab of the sidebar'); + } else if (this.activeRoom.get('type') === OCA.SpreedMe.app.ROOM_TYPE_PUBLIC) { + messageAdditional = t('spreed', 'Share this link to invite others!'); + + if (this.activeRoom.get('participantType') === OCA.SpreedMe.app.OWNER || this.activeRoom.get('participantType') === OCA.SpreedMe.app.MODERATOR) { + messageAdditional = t('spreed', 'You can invite others in the participant tab of the sidebar or share this link to invite others!'); + } + + url = window.location.protocol + '//' + window.location.host + OC.generateUrl('/call/' + this.activeRoom.get('token')); } OCA.SpreedMe.app.setEmptyContentMessage(icon, message, messageAdditional, url);