Merge pull request #598 from damencho/minimize-document-modifications

Minimize document modifications on every presence
This commit is contained in:
bgrozev 2016-04-09 21:57:16 -05:00
commit 26443b6d72
3 changed files with 28 additions and 8 deletions

View File

@ -153,12 +153,14 @@ var ContactList = {
}, },
onDisplayNameChange (id, displayName) { onDisplayNameChange (id, displayName) {
if(!displayName)
return;
if (id === 'localVideoContainer') { if (id === 'localVideoContainer') {
id = APP.conference.localId; id = APP.conference.localId;
} }
let contactName = $(`#contacts #${id}>p`); let contactName = $(`#contacts #${id}>p`);
if (displayName) { if (contactName.text() !== displayName) {
contactName.text(displayName); contactName.text(displayName);
} }
}, },

View File

@ -270,6 +270,17 @@ ConnectionIndicator.prototype.create = function () {
APP.translation.translateString("connectionindicator.na") + "</div>", APP.translation.translateString("connectionindicator.na") + "</div>",
skin: "black"}); skin: "black"});
// override popover show method to make sure we will update the content
// before showing the popover
var origShowFunc = this.popover.show;
this.popover.show = function () {
// update content by forcing it, to finish even if popover
// is not visible
this.updatePopoverData(true);
// call the original show, passing its actual this
origShowFunc.call(this.popover);
}.bind(this);
this.emptyIcon = this.connectionIndicatorContainer.appendChild( this.emptyIcon = this.connectionIndicatorContainer.appendChild(
createIcon(["connection", "connection_empty"])); createIcon(["connection", "connection_empty"]));
this.fullIcon = this.connectionIndicatorContainer.appendChild( this.fullIcon = this.connectionIndicatorContainer.appendChild(
@ -335,13 +346,18 @@ ConnectionIndicator.prototype.updateResolution = function (resolution) {
}; };
/** /**
* Updates the content of the popover * Updates the content of the popover if its visible
* @param force to work even if popover is not visible
*/ */
ConnectionIndicator.prototype.updatePopoverData = function () { ConnectionIndicator.prototype.updatePopoverData = function (force) {
this.popover.updateContent( // generate content, translate it and add it to document only if
`<div class="connection_info">${this.generateText()}</div>` // popover is visible or we force to do so.
); if(this.popover.popoverShown || force) {
APP.translation.translateElement($(".connection_info")); this.popover.updateContent(
`<div class="connection_info">${this.generateText()}</div>`
);
APP.translation.translateElement($(".connection_info"));
}
}; };
/** /**

View File

@ -357,7 +357,9 @@ RemoteVideo.prototype.setDisplayName = function(displayName, key) {
// If we already have a display name for this video. // If we already have a display name for this video.
if (nameSpan.length > 0) { if (nameSpan.length > 0) {
if (displayName && displayName.length > 0) { if (displayName && displayName.length > 0) {
$('#' + this.videoSpanId + '_name').text(displayName); var displaynameSpan = $('#' + this.videoSpanId + '_name');
if (displaynameSpan.text() !== displayName)
displaynameSpan.text(displayName);
} }
else if (key && key.length > 0) { else if (key && key.length > 0) {
var nameHtml = APP.translation.generateTranslationHTML(key); var nameHtml = APP.translation.generateTranslationHTML(key);