зеркало из https://github.com/nextcloud/spreed.git
Merge pull request #502 from nextcloud/bugfix/noid/fix-room-messages-with-room-call-split
Adjust the room/call message while waiting for a call
This commit is contained in:
Коммит
700c9dd864
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function(OCA, Marionette, Backbone, _) {
|
(function(OC, OCA, Marionette, Backbone, _, $) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
OCA.SpreedMe = OCA.SpreedMe || {};
|
OCA.SpreedMe = OCA.SpreedMe || {};
|
||||||
|
@ -725,4 +725,4 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
OCA.SpreedMe.App = App;
|
OCA.SpreedMe.App = App;
|
||||||
})(OCA, Marionette, Backbone, _);
|
})(OC, OCA, Marionette, Backbone, _, $);
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
(function(OC, OCA, Marionette, Handlebars) {
|
(function(OC, OCA, Marionette, Handlebars, _, $) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
OCA.SpreedMe = OCA.SpreedMe || {};
|
OCA.SpreedMe = OCA.SpreedMe || {};
|
||||||
|
@ -71,6 +71,15 @@
|
||||||
'change:participants': function() {
|
'change:participants': function() {
|
||||||
this.render();
|
this.render();
|
||||||
},
|
},
|
||||||
|
'change:hasCall': function() {
|
||||||
|
this.render();
|
||||||
|
},
|
||||||
|
'change:participantInCall': function() {
|
||||||
|
this.render();
|
||||||
|
},
|
||||||
|
'change:participantType': function() {
|
||||||
|
this.render();
|
||||||
|
},
|
||||||
'change:type': function() {
|
'change:type': function() {
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
@ -207,23 +216,27 @@
|
||||||
}, OC.generateUrl('/call/' + token));
|
}, OC.generateUrl('/call/' + token));
|
||||||
},
|
},
|
||||||
addRoomMessage: function() {
|
addRoomMessage: function() {
|
||||||
var message, messageAdditional, participants;
|
var message = '',
|
||||||
|
messageAdditional = '',
|
||||||
|
participants = this.model.get('participants'),
|
||||||
|
hasCall = this.model.get('hasCall'),
|
||||||
|
isInCall = this.model.get('participantInCall');
|
||||||
|
|
||||||
//Remove previous icon, avatar or link from emptycontent
|
//Remove previous icon, avatar or link from emptycontent
|
||||||
var emptyContentIcon = document.getElementById('emptycontent-icon');
|
var $emptyContentIcon = $('#emptycontent-icon');
|
||||||
emptyContentIcon.removeAttribute('class');
|
$emptyContentIcon.attr('class', '')
|
||||||
emptyContentIcon.innerHTML = '';
|
.empty();
|
||||||
$('#shareRoomInput').addClass('hidden');
|
$('#shareRoomInput').addClass('hidden');
|
||||||
$('#shareRoomClipboardButton').addClass('hidden');
|
$('#shareRoomClipboardButton').addClass('hidden');
|
||||||
|
|
||||||
participants = this.model.get('participants');
|
|
||||||
|
|
||||||
switch(this.model.get('type')) {
|
switch(this.model.get('type')) {
|
||||||
case ROOM_TYPE_ONE_TO_ONE:
|
case ROOM_TYPE_ONE_TO_ONE:
|
||||||
var waitingParticipantId, waitingParticipantName;
|
var waitingParticipantId = '',
|
||||||
|
waitingParticipantName = '';
|
||||||
|
|
||||||
$.each(participants, function(participantId, data) {
|
_.each(participants, function(data, participantId) {
|
||||||
if (oc_current_user !== participantId) {
|
if (OC.getCurrentUser().uid !== participantId) {
|
||||||
waitingParticipantId = participantId;
|
waitingParticipantId = participantId;
|
||||||
waitingParticipantName = data.name;
|
waitingParticipantName = data.name;
|
||||||
}
|
}
|
||||||
|
@ -233,9 +246,9 @@
|
||||||
var avatar = document.createElement('div');
|
var avatar = document.createElement('div');
|
||||||
avatar.className = 'avatar room-avatar';
|
avatar.className = 'avatar room-avatar';
|
||||||
|
|
||||||
$('#emptycontent-icon').append(avatar);
|
$emptyContentIcon.append(avatar);
|
||||||
|
|
||||||
$('#emptycontent-icon').find('.avatar').each(function () {
|
$emptyContentIcon.find('.avatar').each(function () {
|
||||||
if (waitingParticipantName && (waitingParticipantId !== waitingParticipantName)) {
|
if (waitingParticipantName && (waitingParticipantId !== waitingParticipantName)) {
|
||||||
$(this).avatar(waitingParticipantId, 128, undefined, false, undefined, waitingParticipantName);
|
$(this).avatar(waitingParticipantId, 128, undefined, false, undefined, waitingParticipantName);
|
||||||
} else {
|
} else {
|
||||||
|
@ -243,33 +256,105 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
message = t('spreed', 'Waiting for {participantName} to join the call …', {participantName: waitingParticipantName});
|
message = t('spreed', 'Waiting for {participantName} to join the room …', {participantName: waitingParticipantName});
|
||||||
messageAdditional = '';
|
if (hasCall) {
|
||||||
break;
|
if (isInCall) {
|
||||||
case ROOM_TYPE_GROUP_CALL:
|
message = t('spreed', 'Waiting for {participantName} to join the call …', {participantName: waitingParticipantName});
|
||||||
if (Object.keys(participants).length > 1) {
|
} else {
|
||||||
message = t('spreed', 'Waiting for others to join the call …');
|
message = t('spreed', '{participantName} is waiting for you to join the call …', {participantName: waitingParticipantName});
|
||||||
messageAdditional = '';
|
}
|
||||||
} else {
|
|
||||||
message = t('spreed', 'No other people in this call');
|
|
||||||
messageAdditional = t('spreed', 'You can invite others by clicking "+ Add person" in the call menu.');
|
|
||||||
}
|
}
|
||||||
$('#emptycontent-icon').addClass('icon-contacts-dark');
|
|
||||||
break;
|
break;
|
||||||
case ROOM_TYPE_PUBLIC_CALL:
|
case ROOM_TYPE_PUBLIC_CALL:
|
||||||
if (Object.keys(participants).length > 1) {
|
case ROOM_TYPE_GROUP_CALL:
|
||||||
message = t('spreed', 'Waiting for others to join the call …');
|
message = t('spreed', 'Waiting for others to join the room …');
|
||||||
} else {
|
|
||||||
message = t('spreed', 'No other people in this call');
|
|
||||||
}
|
|
||||||
messageAdditional = t('spreed', 'Share this link to invite others!');
|
|
||||||
$('#emptycontent-icon').addClass('icon-public');
|
|
||||||
|
|
||||||
//Add link
|
if (OC.getCurrentUser().uid !== null && Object.keys(participants).length === 1) {
|
||||||
var url = window.location.protocol + '//' + window.location.host + OC.generateUrl('/call/' + this.model.get('token'));
|
message = t('spreed', 'No other people in this call');
|
||||||
$('#shareRoomInput').val(url);
|
if (this.model.get('participantType') === 0 || this.model.get('participantType') === 1) {
|
||||||
$('#shareRoomInput').removeClass('hidden');
|
messageAdditional = t('spreed', 'You can invite others in the participant tab of the sidebar');
|
||||||
$('#shareRoomClipboardButton').removeClass('hidden');
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasCall) {
|
||||||
|
$emptyContentIcon.addClass('icon-video');
|
||||||
|
if (isInCall) {
|
||||||
|
message = t('spreed', 'Waiting for others to join the call …');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
var others = [];
|
||||||
|
_.each(participants, function(data) {
|
||||||
|
if (data.call) {
|
||||||
|
others.push(data.name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (others.length === 1) {
|
||||||
|
message = t('spreed', '{participantName} is waiting for you to join the call …', {participantName: others[0]});
|
||||||
|
} else {
|
||||||
|
message = t('spreed', 'Call in progress …');
|
||||||
|
switch (others.length) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
messageAdditional = t('spreed', 'Join {participant1} and {participant2}', {
|
||||||
|
participant1: others[0],
|
||||||
|
participant2: others[1]
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
messageAdditional = t('spreed', 'Join {participant1}, {participant2} and {participant3}', {
|
||||||
|
participant1: others[0],
|
||||||
|
participant2: others[1],
|
||||||
|
participant3: others[2]
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
messageAdditional = t('spreed', 'Join {participant1}, {participant2}, {participant3} and {participant4}', {
|
||||||
|
participant1: others[0],
|
||||||
|
participant2: others[1],
|
||||||
|
participant3: others[2],
|
||||||
|
participant4: others[3]
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
messageAdditional = t('spreed', 'Join {participant1}, {participant2}, {participant3}, {participant4} and {participant5}', {
|
||||||
|
participant1: others[0],
|
||||||
|
participant2: others[1],
|
||||||
|
participant3: others[2],
|
||||||
|
participant4: others[3],
|
||||||
|
participant5: others[4]
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
messageAdditional = t('spreed', 'Join {participant1}, {participant2}, {participant3}, {participant4}, …', {
|
||||||
|
participant1: others[0],
|
||||||
|
participant2: others[1],
|
||||||
|
participant3: others[2],
|
||||||
|
participant4: others[3]
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (this.model.get('type') === ROOM_TYPE_PUBLIC_CALL) {
|
||||||
|
$emptyContentIcon.addClass('icon-public');
|
||||||
|
} else {
|
||||||
|
$emptyContentIcon.addClass('icon-contacts-dark');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (messageAdditional === '' && this.model.get('type') === ROOM_TYPE_PUBLIC_CALL) {
|
||||||
|
messageAdditional = t('spreed', 'Share this link to invite others!');
|
||||||
|
|
||||||
|
//Add link
|
||||||
|
var url = window.location.protocol + '//' + window.location.host + OC.generateUrl('/call/' + this.model.get('token'));
|
||||||
|
$('#shareRoomInput').val(url);
|
||||||
|
$('#shareRoomInput').removeClass('hidden');
|
||||||
|
$('#shareRoomClipboardButton').removeClass('hidden');
|
||||||
|
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log("Unknown room type", this.model.get('type'));
|
console.log("Unknown room type", this.model.get('type'));
|
||||||
|
@ -315,4 +400,4 @@
|
||||||
|
|
||||||
OCA.SpreedMe.Views.RoomListView = RoomListView;
|
OCA.SpreedMe.Views.RoomListView = RoomListView;
|
||||||
|
|
||||||
})(OC, OCA, Marionette, Handlebars);
|
})(OC, OCA, Marionette, Handlebars, _, $);
|
||||||
|
|
|
@ -169,6 +169,7 @@ class RoomController extends OCSController {
|
||||||
'participantInCall' => $participantInCall,
|
'participantInCall' => $participantInCall,
|
||||||
'count' => $room->getNumberOfParticipants(time() - 30),
|
'count' => $room->getNumberOfParticipants(time() - 30),
|
||||||
'hasPassword' => $room->hasPassword(),
|
'hasPassword' => $room->hasPassword(),
|
||||||
|
'hasCall' => $room->getActiveSince() instanceof \DateTimeInterface,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!$participant instanceof Participant) {
|
if (!$participant instanceof Participant) {
|
||||||
|
@ -178,6 +179,7 @@ class RoomController extends OCSController {
|
||||||
'sessionId' => '0',
|
'sessionId' => '0',
|
||||||
'participants' => [],
|
'participants' => [],
|
||||||
'numGuests' => 0,
|
'numGuests' => 0,
|
||||||
|
'hasCall' => false,
|
||||||
'guestList' => '',
|
'guestList' => '',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -200,6 +202,7 @@ class RoomController extends OCSController {
|
||||||
$participantList[$user->getUID()] = [
|
$participantList[$user->getUID()] = [
|
||||||
'name' => $user->getDisplayName(),
|
'name' => $user->getDisplayName(),
|
||||||
'type' => $data['participantType'],
|
'type' => $data['participantType'],
|
||||||
|
'call' => $data['inCall'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче