loleaflet/src/layer/AnnotationManager.js |   16 ++++++++--------
 loleaflet/src/map/Map.js                 |   12 ++++++------
 2 files changed, 14 insertions(+), 14 deletions(-)

New commits:
commit fe850f69fab8dce819f82ba240edb3ca4d1ae8d3
Author: Pranav Kant <[email protected]>
Date:   Wed Oct 11 14:45:50 2017 +0200

    loleaflet: The comment JSON has user name, not userid
    
    We register the full names of the user with libreoffice core, not user
    ids. Create a viewinfo map mapping usernames with viewinfo, not userids
    with viewinfo.
    
    This fixes the regression: the avatar URL doesn't work.
    
    Change-Id: Ie4cc75168c7480fcb663414f3a082264b42c11d9
    (cherry picked from commit 981d810f1dbe56eb452d8979b43199b305fd4e6f)
    Reviewed-on: https://gerrit.libreoffice.org/43326
    Reviewed-by: Jan Holesovsky <[email protected]>
    Tested-by: Jan Holesovsky <[email protected]>

diff --git a/loleaflet/src/layer/AnnotationManager.js 
b/loleaflet/src/layer/AnnotationManager.js
index d6306487..6ab038ea 100644
--- a/loleaflet/src/layer/AnnotationManager.js
+++ b/loleaflet/src/layer/AnnotationManager.js
@@ -131,8 +131,8 @@ L.AnnotationManager = L.Class.extend({
                for (var index in comments) {
                        comment = comments[index];
                        this.adjustComment(comment);
-                       if (comment.author in this._map._viewInfoByUser) {
-                               comment.avatar = 
this._map._viewInfoByUser[comment.author].userextrainfo.avatar;
+                       if (comment.author in this._map._viewInfoByUserName) {
+                               comment.avatar = 
this._map._viewInfoByUserName[comment.author].userextrainfo.avatar;
                        }
                        
this._items.push(L.annotation(this._map.options.maxBounds.getSouthEast(), 
comment).addTo(this._map));
                }
@@ -159,8 +159,8 @@ L.AnnotationManager = L.Class.extend({
                                // something wrong in this redline, skip this 
one
                                continue;
                        }
-                       if (changecomment.author in this._map._viewInfoByUser) {
-                               changecomment.avatar = 
this._map._viewInfoByUser[changecomment.author].userextrainfo.avatar;
+                       if (changecomment.author in 
this._map._viewInfoByUserName) {
+                               changecomment.avatar = 
this._map._viewInfoByUserName[changecomment.author].userextrainfo.avatar;
                        }
                        
this._items.push(L.annotation(this._map.options.maxBounds.getSouthEast(), 
changecomment).addTo(this._map));
                }
@@ -534,11 +534,11 @@ L.AnnotationManager = L.Class.extend({
                var changetrack = obj.redline ? true : false;
                var action = changetrack ? obj.redline.action : 
obj.comment.action;
 
-               if (changetrack && obj.redline.author in 
this._map._viewInfoByUser) {
-                       obj.redline.avatar = 
this._map._viewInfoByUser[obj.redline.author].userextrainfo.avatar;
+               if (changetrack && obj.redline.author in 
this._map._viewInfoByUserName) {
+                       obj.redline.avatar = 
this._map._viewInfoByUserName[obj.redline.author].userextrainfo.avatar;
                }
-               else if (!changetrack && obj.comment.author in 
this._map._viewInfoByUser) {
-                       obj.comment.avatar = 
this._map._viewInfoByUser[obj.comment.author].userextrainfo.avatar;
+               else if (!changetrack && obj.comment.author in 
this._map._viewInfoByUserName) {
+                       obj.comment.avatar = 
this._map._viewInfoByUserName[obj.comment.author].userextrainfo.avatar;
                }
 
                if (action === 'Add') {
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index d1d04d62..48a535e2 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -136,7 +136,7 @@ L.Map = L.Evented.extend({
 
                // View info (user names and view ids)
                this._viewInfo = {};
-               this._viewInfoByUser = {};
+               this._viewInfoByUserName = {};
 
                // View color map
                this._viewColors = {};
@@ -168,7 +168,7 @@ L.Map = L.Evented.extend({
        addView: function(viewInfo) {
                this._viewInfo[viewInfo.id] = viewInfo;
                if (viewInfo.userextrainfo !== undefined && 
viewInfo.userextrainfo.avatar !== undefined) {
-                       this._viewInfoByUser[viewInfo.userid] = viewInfo;
+                       this._viewInfoByUserName[viewInfo.username] = viewInfo;
                }
                this.fire('postMessage', {msgId: 'View_Added', args: {ViewId: 
viewInfo.id, UserId: viewInfo.userid, UserName: viewInfo.username, 
UserExtraInfo: viewInfo.userextrainfo, Color: viewInfo.color, ReadOnly: 
viewInfo.readonly}});
 
@@ -180,7 +180,7 @@ L.Map = L.Evented.extend({
 
        removeView: function(viewid) {
                var username = this._viewInfo[viewid].username;
-               delete this._viewInfoByUser[this._viewInfo[viewid].userid];
+               delete 
this._viewInfoByUserName[this._viewInfo[viewid].username];
                delete this._viewInfo[viewid];
                this.fire('postMessage', {msgId: 'View_Removed', args: {ViewId: 
viewid}});
 
@@ -199,9 +199,9 @@ L.Map = L.Evented.extend({
        updateAvatars: function() {
                if (this._docLayer && this._docLayer._annotations && 
this._docLayer._annotations._items) {
                        for (var idxAnno in this._docLayer._annotations._items) 
{
-                               var userid = 
this._docLayer._annotations._items[idxAnno]._data.author;
-                               if (this._viewInfoByUser[userid]) {
-                                       
$(this._docLayer._annotations._items[idxAnno]._authorAvatarImg).attr('src', 
this._viewInfoByUser[userid].userextrainfo.avatar);
+                               var username = 
this._docLayer._annotations._items[idxAnno]._data.author;
+                               if (this._viewInfoByUserName[username]) {
+                                       
$(this._docLayer._annotations._items[idxAnno]._authorAvatarImg).attr('src', 
this._viewInfoByUserName[username].userextrainfo.avatar);
                                }
                        }
                }
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to