From b154777f5a37ef91f9dafba991ba50ee5f1cbd12 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Fri, 2 Jul 2021 17:49:53 +0300 Subject: [PATCH] [mobile] Fix user name in comments (2) --- .../lib/controller/collaboration/Comments.jsx | 18 +++++++++--------- .../lib/controller/collaboration/Review.jsx | 5 +++-- apps/common/mobile/lib/store/comments.js | 1 + apps/common/mobile/lib/store/users.js | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/apps/common/mobile/lib/controller/collaboration/Comments.jsx b/apps/common/mobile/lib/controller/collaboration/Comments.jsx index b9f9d9d5d..db68b4ff1 100644 --- a/apps/common/mobile/lib/controller/collaboration/Comments.jsx +++ b/apps/common/mobile/lib/controller/collaboration/Comments.jsx @@ -44,9 +44,7 @@ const dateToLocaleTimeString = (date) => { return (date.getMonth() + 1) + '/' + (date.getDate()) + '/' + date.getFullYear() + ' ' + format(date); }; const parseUserName = name => { - return ( - Common.Utils.String.htmlEncode(AscCommon.UserInfoParser.getParsedName(name)) - ) + return AscCommon.UserInfoParser.getParsedName(name); }; //end utils @@ -129,11 +127,13 @@ class CommentsController extends Component { let user = this.usersStore.searchUserById(data.asc_getUserId()); const name = data.asc_getUserName(); + const parsedName = parseUserName(name); changeComment.comment = data.asc_getText(); changeComment.userId = data.asc_getUserId(); changeComment.userName = name; - changeComment.parsedName = parseUserName(name); + changeComment.parsedName = Common.Utils.String.htmlEncode(parsedName); + changeComment.userInitials = this.usersStore.getInitials(parsedName); changeComment.userColor = (user) ? user.asc_getColor() : null; changeComment.resolved = data.asc_getSolved(); changeComment.quote = data.asc_getQuoteText(); @@ -158,7 +158,7 @@ class CommentsController extends Component { ind: i, userId: data.asc_getReply(i).asc_getUserId(), userName: userName, - parsedName: parsedName, + parsedName: Common.Utils.String.htmlEncode(parsedName), userColor: (user) ? user.asc_getColor() : null, date: dateToLocaleTimeString(dateReply), reply: data.asc_getReply(i).asc_getText(), @@ -186,7 +186,7 @@ class CommentsController extends Component { uid : id, userId : data.asc_getUserId(), userName : userName, - parsedName : parsedName, + parsedName : Common.Utils.String.htmlEncode(parsedName), userColor : (user) ? user.asc_getColor() : null, date : dateToLocaleTimeString(date), quote : data.asc_getQuoteText(), @@ -224,7 +224,7 @@ class CommentsController extends Component { ind : i, userId : data.asc_getReply(i).asc_getUserId(), userName : userName, - parsedName : parsedName, + parsedName : Common.Utils.String.htmlEncode(parsedName), userColor : (user) ? user.asc_getColor() : null, date : dateToLocaleTimeString(date), reply : data.asc_getReply(i).asc_getText(), @@ -267,7 +267,7 @@ class AddCommentController extends Component { } const name = parseUserName(this.currentUser.asc_getUserName()); return { - name: name, + name: Common.Utils.String.htmlEncode(name), initials: this.props.users.getInitials(name), color: this.currentUser.asc_getColor() }; @@ -311,7 +311,7 @@ class EditCommentController extends Component { this.currentUser = this.props.users.currentUser; const name = parseUserName(this.currentUser.asc_getUserName()); return { - name: name, + name: Common.Utils.String.htmlEncode(name), initials: this.props.users.getInitials(name), color: this.currentUser.asc_getColor() }; diff --git a/apps/common/mobile/lib/controller/collaboration/Review.jsx b/apps/common/mobile/lib/controller/collaboration/Review.jsx index d8a42eaf7..830ab10de 100644 --- a/apps/common/mobile/lib/controller/collaboration/Review.jsx +++ b/apps/common/mobile/lib/controller/collaboration/Review.jsx @@ -468,13 +468,14 @@ class ReviewChange extends Component { let change; let goto = false; if (arrChangeReview.length > 0) { + const name = AscCommon.UserInfoParser.getParsedName(arrChangeReview[0].user); change = { date: arrChangeReview[0].date, user: arrChangeReview[0].user, - userName: Common.Utils.String.htmlEncode(AscCommon.UserInfoParser.getParsedName(arrChangeReview[0].user)), + userName: Common.Utils.String.htmlEncode(name), color: arrChangeReview[0].userColor.get_hex(), text: arrChangeReview[0].changeText, - initials: this.props.users.getInitials(arrChangeReview[0].user), + initials: this.props.users.getInitials(name), editable: arrChangeReview[0].editable }; goto = arrChangeReview[0].goto; diff --git a/apps/common/mobile/lib/store/comments.js b/apps/common/mobile/lib/store/comments.js index 5fea1e057..8163b1917 100644 --- a/apps/common/mobile/lib/store/comments.js +++ b/apps/common/mobile/lib/store/comments.js @@ -71,6 +71,7 @@ export class storeComments { comment.userId = changeComment.userId; comment.userName = changeComment.userName; comment.parsedName = changeComment.parsedName; + comment.userInitials = changeComment.userInitials; comment.userColor = changeComment.userColor; comment.resolved = changeComment.resolved; comment.quote = changeComment.quote; diff --git a/apps/common/mobile/lib/store/users.js b/apps/common/mobile/lib/store/users.js index 776c6e408..b13152b94 100644 --- a/apps/common/mobile/lib/store/users.js +++ b/apps/common/mobile/lib/store/users.js @@ -52,7 +52,7 @@ export class storeUsers { } getInitials (name) { - const fio = AscCommon.UserInfoParser.getParsedName(name).split(' '); + const fio = name.split(' '); let initials = fio[0].substring(0, 1).toUpperCase(); for (let i = fio.length-1; i>0; i--) { if (fio[i][0]!=='(' && fio[i][0]!==')') {