loleaflet/src/control/Control.UserList.js | 40 ++++++++++++++++++------------ 1 file changed, 25 insertions(+), 15 deletions(-)
New commits: commit 449dc691d2d2ebcc6d81410f536b0fc04ff8b0bd Author: Andras Timar <andras.ti...@collabora.com> AuthorDate: Wed Aug 19 11:19:08 2020 +0200 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed Aug 19 11:25:22 2020 +0200 do not show broken images instead of avatars Change-Id: I6babd0a892dccc2ca5d6d1bf6ac6e6007411b1e2 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100977 Tested-by: Andras Timar <andras.ti...@collabora.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/loleaflet/src/control/Control.UserList.js b/loleaflet/src/control/Control.UserList.js index 9a7c27386..949394e4f 100644 --- a/loleaflet/src/control/Control.UserList.js +++ b/loleaflet/src/control/Control.UserList.js @@ -85,7 +85,17 @@ L.Control.UserList = L.Control.extend({ var iconTd = L.DomUtil.create('td', 'usercolor', content); var nameTd = L.DomUtil.create('td', 'username loleaflet-font', content); + var hasAvatar = false; if (extraInfo !== undefined && extraInfo.avatar !== undefined) { + var http = new XMLHttpRequest(); + http.open('HEAD', extraInfo.avatar, false); + http.send(); + if (http.status != 404) { + hasAvatar = true; + } + } + + if (hasAvatar) { var img = L.DomUtil.create('img', 'avatar-img', iconTd); img.src = extraInfo.avatar; $(img).css({'border-color': color}); @@ -93,9 +103,9 @@ L.Control.UserList = L.Control.extend({ img = L.DomUtil.create('div', 'user-info', iconTd); $(img).css({'background-color': color}); } - + nameTd.innerHTML = userName; - + return content; }, @@ -105,7 +115,7 @@ L.Control.UserList = L.Control.extend({ if (userlistItem == null) { return; } - + var count = $(userlistItem.html).find('#userlist_table tbody tr').length; if (count > 1) { userlistItem.text = this.options.nUsers.replace('%n', count); @@ -114,9 +124,9 @@ L.Control.UserList = L.Control.extend({ } else { userlistItem.text = this.options.noUser; } - + w2ui['actionbar'].refresh(); - + var hideUserList = window.ThisIsAMobileApp || (this.map['wopi'].HideUserList !== null && this.map['wopi'].HideUserList !== undefined && @@ -124,7 +134,7 @@ L.Control.UserList = L.Control.extend({ (window.mode.isMobile() && $.inArray('mobile', this.map['wopi'].HideUserList) >= 0) || (window.mode.isTablet() && $.inArray('tablet', this.map['wopi'].HideUserList) >= 0) || (window.mode.isDesktop() && $.inArray('desktop', this.map['wopi'].HideUserList) >= 0)); - + if (!hideUserList && count > 1) { actionbar.show('userlist'); actionbar.show('userlistbreak'); @@ -139,7 +149,7 @@ L.Control.UserList = L.Control.extend({ if (userlistItem === null) { return; } - + $('#user-' + e.viewId).removeClass('selected-user'); }, @@ -169,10 +179,10 @@ L.Control.UserList = L.Control.extend({ var userlistItem = w2ui['actionbar'].get('userlist'); var username = this.escapeHtml(e.username); var showPopup = false; - + if (userlistItem !== null) showPopup = $(userlistItem.html).find('#userlist_table tbody tr').length > 0; - + if (showPopup) { $('#tb_actionbar_item_userlist') .w2overlay({ @@ -188,18 +198,18 @@ L.Control.UserList = L.Control.extend({ that.options.userPopupTimeout = null; }, 3000); } - + var color = L.LOUtil.rgbToHex(this.map.getViewColor(e.viewId)); if (e.viewId === this.map._docLayer._viewId) { username = _('You'); color = '#000'; } - + // Mention readonly sessions in userlist if (e.readonly) { username += ' (' + _('Readonly') + ')'; } - + if (userlistItem !== null) { var newhtml = $(userlistItem.html).find('#userlist_table tbody').append(this.getUserItem(e.viewId, username, e.extraInfo, color)).parent().parent()[0].outerHTML; userlistItem.html = newhtml; @@ -221,12 +231,12 @@ L.Control.UserList = L.Control.extend({ clearTimeout(that.options.userPopupTimeout); that.options.userPopupTimeout = null; }, 3000); - + if (e.viewId === this.map._docLayer._followThis) { this.map._docLayer._followThis = -1; this.map._docLayer._followUser = false; } - + var userlistItem = w2ui['actionbar'].get('userlist'); if (userlistItem !== null) { userlistItem.html = $(userlistItem.html).find('#user-' + e.viewId).remove().end()[0].outerHTML; @@ -249,4 +259,4 @@ L.control.createUserListWidget = function () { '</table>' + '<p id="currently-msg">' + _('Current') + ' - <b><span id="current-editor"></span></b></p>' + '</div>'; -}; \ No newline at end of file +}; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits