Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/user avatars #2647

Merged
merged 24 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
165ffa8
Added getUserInitials utils
Basher0303 Jun 13, 2023
d649161
Added user avatar for comments
Basher0303 Jun 13, 2023
4de1f54
Added user avatar for chat
Basher0303 Jun 13, 2023
eb5f542
Added user avatar for users list in header
Basher0303 Jun 13, 2023
7791356
Refactoring previos commits
Basher0303 Jun 14, 2023
5d513b1
Added user avatar for review
Basher0303 Jun 15, 2023
5cf0468
Fix show avatar for comments
Basher0303 Jun 15, 2023
7af5596
Merge branch 'develop' into feature/user-avatars
Basher0303 Jul 3, 2023
026ca0c
Fix rtl for comments and chat
Basher0303 Jul 3, 2023
a4f634c
[SSE DE PE] Added avatar in editor header
Basher0303 Jul 4, 2023
4fc6c06
Api config: add image field to user info
JuliaRadzhabova Oct 7, 2023
2c2a2ec
Add onRequestUserImage/setUserImage events for user avatars
JuliaRadzhabova Oct 9, 2023
847776e
Refactoring loading images for users (use onRequestUsers/setUsers wit…
JuliaRadzhabova Oct 10, 2023
1b6e3c7
Fix user image in review changes
JuliaRadzhabova Oct 10, 2023
673b53e
[SSE DE PE] Change template for user avatar
Basher0303 Oct 11, 2023
9765935
[SSE DE PE] Add avatar in version history
Basher0303 Oct 11, 2023
92a04c7
Merge remote-tracking branch 'origin/feature/user-avatars' into featu…
JuliaRadzhabova Oct 11, 2023
1bee469
Load user images for version history
JuliaRadzhabova Oct 11, 2023
b34aa48
Load users images for comments
JuliaRadzhabova Oct 11, 2023
a6e2f51
Fix user image in comments
JuliaRadzhabova Oct 12, 2023
f7eb7dd
Revert "[SSE DE PE] Change template for user avatar"
Basher0303 Oct 12, 2023
e8fdf7d
[SSE DE PE] Change template for user avatar in version history
Basher0303 Oct 12, 2023
de30839
Fix user images in chat
JuliaRadzhabova Oct 13, 2023
617d11f
Refactoring
JuliaRadzhabova Oct 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/api/documents/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
id: 'user id',
name: 'user name',
group: 'group name' // for customization.reviewPermissions or permissions.reviewGroups or permissions.commentGroups. Can be multiple groups separated by commas (,) : 'Group1' or 'Group1,Group2'
image: 'image url'
},
recent: [
{
Expand Down
4 changes: 2 additions & 2 deletions apps/common/Gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ if (window.Common === undefined) {
_postMessage({event:'onMakeActionLink', data: config});
},

requestUsers: function (command) {
_postMessage({event:'onRequestUsers', data: {c: command}});
requestUsers: function (command, id) {
_postMessage({event:'onRequestUsers', data: {c: command, id: id}});
},

requestSendNotify: function (emails) {
Expand Down
4 changes: 4 additions & 0 deletions apps/common/main/lib/collection/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ define([
function(model){
return model.get('idOriginal') == id;
});
},

findOriginalUsers: function(id) {
return this.where({idOriginal: id});
}
});

Expand Down
42 changes: 40 additions & 2 deletions apps/common/main/lib/controller/Chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ define([
this.api.asc_registerCallback('asc_onCoAuthoringChatReceiveMessage', _.bind(this.onReceiveMessage, this));

if ( !this.mode.isEditDiagram && !this.mode.isEditMailMerge && !this.mode.isEditOle ) {
Common.NotificationCenter.on('mentions:setusers', _.bind(this.avatarsUpdate, this));
this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onUsersChanged, this));
this.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(this.onUserConnection, this));
this.api.asc_coAuthoringGetUsers();
Expand Down Expand Up @@ -138,27 +139,33 @@ define([
var usersStore = this.getApplication().getCollection('Common.Collections.Users');

if (usersStore) {
var arrUsers = [], name, user;
var arrUsers = [], name, user, arrIds = [];

for (name in users) {
if (undefined !== name) {
user = users[name];
if (user) {
var avatar = Common.UI.ExternalUsers.getImage(user.asc_getIdOriginal());
var usermodel = new Common.Models.User({
id : user.asc_getId(),
idOriginal : user.asc_getIdOriginal(),
username : user.asc_getUserName(),
parsedName : AscCommon.UserInfoParser.getParsedName(user.asc_getUserName()),
initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(user.asc_getUserName())),
online : true,
color : user.asc_getColor(),
avatar : avatar,
view : user.asc_getView(),
hidden : !(user.asc_getIdOriginal()===this.currentUserId || AscCommon.UserInfoParser.isUserVisible(user.asc_getUserName()))
});
arrUsers[(user.asc_getId() == currentUserId ) ? 'unshift' : 'push'](usermodel);
(avatar===undefined) && arrIds.push(user.asc_getIdOriginal());
}
}
}

usersStore[usersStore.size() > 0 ? 'add' : 'reset'](arrUsers);
arrIds.length && Common.UI.ExternalUsers.get('info', arrIds);
}
},

Expand All @@ -167,23 +174,53 @@ define([

if (usersStore){
var user = usersStore.findUser(change.asc_getId());
var avatar = Common.UI.ExternalUsers.getImage(change.asc_getIdOriginal());
if (!user) {
usersStore.add(new Common.Models.User({
id : change.asc_getId(),
idOriginal : change.asc_getIdOriginal(),
username : change.asc_getUserName(),
parsedName : AscCommon.UserInfoParser.getParsedName(change.asc_getUserName()),
initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(change.asc_getUserName())),
online : change.asc_getState(),
color : change.asc_getColor(),
avatar : avatar,
view : change.asc_getView(),
hidden : !(change.asc_getIdOriginal()===this.currentUserId || AscCommon.UserInfoParser.isUserVisible(change.asc_getUserName()))
}));
} else {
user.set({online: change.asc_getState()});
user.set({username: change.asc_getUserName()});
user.set({parsedName: AscCommon.UserInfoParser.getParsedName(change.asc_getUserName())});
user.set({initials: Common.Utils.getUserInitials(change.asc_getUserName())});
user.set({avatar: avatar});
}
(avatar===undefined) && Common.UI.ExternalUsers.get('info', [change.asc_getIdOriginal()]);
}
},

avatarsUpdate: function(type, users) {
if (type!=='info') return;

var usersStore = this.getApplication().getCollection('Common.Collections.Users'),
msgStore = this.getApplication().getCollection('Common.Collections.ChatMessages'),
needrender = false;
if (users && users.length>0 ){
_.each(users, function(item) {
usersStore && usersStore.findOriginalUsers(item.id).forEach(function(user){
user.set({avatar: item.image});
});
msgStore && msgStore.where({userid: item.id}).forEach(function(msg){
if (item.image!==undefined && item.image !== msg.get('avatar')) {
needrender = true;
msg.set('avatar', item.image, {silent: true});
}
});
});
}
needrender && this.panelChat && this.panelChat.renderMessages();
},

onReceiveMessage: function(messages, clear){
var msgStore = this.getApplication().getCollection('Common.Collections.ChatMessages');

Expand All @@ -193,7 +230,8 @@ define([
array.push(new Common.Models.ChatMessage({
userid : msg.useridoriginal,
message : msg.message,
username : msg.username
username : msg.username,
parsedName : AscCommon.UserInfoParser.getParsedName(msg.username),
}));
});

Expand Down
Loading
Loading