зеркало из https://github.com/nextcloud/spreed.git
Move updating the room message ouf of the room list view
The room message should be updated as a response to a change of the active room, and not when the room list view is rendered. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Родитель
9f49baea0e
Коммит
77dbeb9dc3
58
js/app.js
58
js/app.js
|
@ -493,6 +493,7 @@
|
|||
}
|
||||
});
|
||||
participants = self.activeRoom.get('participants');
|
||||
self.setRoomMessageForUser();
|
||||
} else {
|
||||
// The public page supports only a single room, so the
|
||||
// active room is already the room for the given token.
|
||||
|
@ -626,6 +627,63 @@
|
|||
restoreEmptyContent: function() {
|
||||
this.setEmptyContentMessage.apply(this, this._lastEmptyContent);
|
||||
},
|
||||
setRoomMessageForUser: function() {
|
||||
var participants = this.activeRoom.get('participants');
|
||||
|
||||
switch(this.activeRoom.get('type')) {
|
||||
case OCA.SpreedMe.app.ROOM_TYPE_ONE_TO_ONE:
|
||||
var participantId = '',
|
||||
participantName = '';
|
||||
|
||||
_.each(participants, function(data, userId) {
|
||||
if (OC.getCurrentUser().uid !== userId) {
|
||||
participantId = userId;
|
||||
participantName = data.name;
|
||||
}
|
||||
});
|
||||
|
||||
OCA.SpreedMe.app.setEmptyContentMessage(
|
||||
{ userId: participantId, displayName: participantName},
|
||||
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:
|
||||
var icon = '',
|
||||
message = '',
|
||||
messageAdditional = '',
|
||||
url = '';
|
||||
|
||||
if (this.activeRoom.get('type') === OCA.SpreedMe.app.ROOM_TYPE_PUBLIC) {
|
||||
icon = 'icon-public';
|
||||
} else {
|
||||
icon = 'icon-contacts-dark';
|
||||
}
|
||||
|
||||
message = t('spreed', 'Waiting for others to join the call …');
|
||||
|
||||
if (OC.getCurrentUser().uid !== null && Object.keys(participants).length === 1) {
|
||||
message = t('spreed', 'No other people in this call');
|
||||
if (this.activeRoom.get('participantType') === 0 || this.activeRoom.get('participantType') === 1) {
|
||||
messageAdditional = t('spreed', 'You can invite others in the participant tab of the sidebar');
|
||||
}
|
||||
}
|
||||
|
||||
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') === 1 || this.activeRoom.get('participantType') === 2) {
|
||||
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);
|
||||
break;
|
||||
default:
|
||||
console.log("Unknown room type", this.activeRoom.get('type'));
|
||||
return;
|
||||
}
|
||||
},
|
||||
setRoomMessageForGuest: function() {
|
||||
var participants = this.activeRoom.get('participants');
|
||||
|
||||
|
|
|
@ -176,9 +176,6 @@
|
|||
this.$el.find('.app-navigation-entry-link').attr('href', roomURL);
|
||||
|
||||
if (this.model.get('active')) {
|
||||
if (!this.$el.hasClass('active')) {
|
||||
this.addRoomMessage();
|
||||
}
|
||||
this.$el.addClass('active');
|
||||
} else {
|
||||
this.$el.removeClass('active');
|
||||
|
@ -331,64 +328,6 @@
|
|||
token: token
|
||||
}, OC.generateUrl('/call/' + token));
|
||||
},
|
||||
addRoomMessage: function() {
|
||||
console.log('addRoomMessage');
|
||||
var participants = this.model.get('participants');
|
||||
|
||||
switch(this.model.get('type')) {
|
||||
case OCA.SpreedMe.app.ROOM_TYPE_ONE_TO_ONE:
|
||||
var participantId = '',
|
||||
participantName = '';
|
||||
|
||||
_.each(participants, function(data, userId) {
|
||||
if (OC.getCurrentUser().uid !== userId) {
|
||||
participantId = userId;
|
||||
participantName = data.name;
|
||||
}
|
||||
});
|
||||
|
||||
OCA.SpreedMe.app.setEmptyContentMessage(
|
||||
{ userId: participantId, displayName: participantName},
|
||||
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:
|
||||
var icon = '',
|
||||
message = '',
|
||||
messageAdditional = '',
|
||||
url = '';
|
||||
|
||||
if (this.model.get('type') === OCA.SpreedMe.app.ROOM_TYPE_PUBLIC) {
|
||||
icon = 'icon-public';
|
||||
} else {
|
||||
icon = 'icon-contacts-dark';
|
||||
}
|
||||
|
||||
message = t('spreed', 'Waiting for others to join the call …');
|
||||
|
||||
if (OC.getCurrentUser().uid !== null && Object.keys(participants).length === 1) {
|
||||
message = t('spreed', 'No other people in this call');
|
||||
if (this.model.get('participantType') === 0 || this.model.get('participantType') === 1) {
|
||||
messageAdditional = t('spreed', 'You can invite others in the participant tab of the sidebar');
|
||||
}
|
||||
}
|
||||
|
||||
if (this.model.get('type') === OCA.SpreedMe.app.ROOM_TYPE_PUBLIC) {
|
||||
messageAdditional = t('spreed', 'Share this link to invite others!');
|
||||
if (this.model.get('participantType') === 1 || this.model.get('participantType') === 2) {
|
||||
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.model.get('token'));
|
||||
}
|
||||
|
||||
OCA.SpreedMe.app.setEmptyContentMessage(icon, message, messageAdditional, url);
|
||||
break;
|
||||
default:
|
||||
console.log("Unknown room type", this.model.get('type'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var RoomListView = Marionette.CollectionView.extend({
|
||||
|
|
Загрузка…
Ссылка в новой задаче