[Libreoffice-commits] online.git: loleaflet/src
Pranav Kant
pranavk at collabora.co.uk
Wed Oct 11 12:47:50 UTC 2017
loleaflet/src/layer/AnnotationManager.js | 16 ++++++++--------
loleaflet/src/map/Map.js | 12 ++++++------
2 files changed, 14 insertions(+), 14 deletions(-)
New commits:
commit 981d810f1dbe56eb452d8979b43199b305fd4e6f
Author: Pranav Kant <pranavk at collabora.co.uk>
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
diff --git a/loleaflet/src/layer/AnnotationManager.js b/loleaflet/src/layer/AnnotationManager.js
index 06513ba9..31580bd5 100644
--- a/loleaflet/src/layer/AnnotationManager.js
+++ b/loleaflet/src/layer/AnnotationManager.js
@@ -123,8 +123,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));
}
@@ -151,8 +151,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));
}
@@ -526,11 +526,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 79856073..bdd3e47a 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -139,7 +139,7 @@ L.Map = L.Evented.extend({
// View info (user names and view ids)
this._viewInfo = {};
- this._viewInfoByUser = {};
+ this._viewInfoByUserName = {};
// View color map
this._viewColors = {};
@@ -187,7 +187,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: L.LOUtil.rgbToHex(viewInfo.color), ReadOnly: viewInfo.readonly}});
@@ -199,7 +199,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}});
@@ -218,9 +218,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);
}
}
}
More information about the Libreoffice-commits
mailing list