From 64b8e12ff680460da585f714e39bf2a9968e73c1 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 2 Jul 2021 14:27:16 +0300 Subject: [PATCH 1/4] [Mobile] Fix user name in comments --- .../lib/view/collaboration/Comments.jsx | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/apps/common/mobile/lib/view/collaboration/Comments.jsx b/apps/common/mobile/lib/view/collaboration/Comments.jsx index d403f8cbb..23be9fae5 100644 --- a/apps/common/mobile/lib/view/collaboration/Comments.jsx +++ b/apps/common/mobile/lib/view/collaboration/Comments.jsx @@ -56,7 +56,7 @@ const AddCommentPopup = inject("storeComments")(observer(props => { {Device.android &&
{userInfo.initials}
} -
{userInfo.name}
+
{GetUserName(userInfo.name)}
{setText(event.target.value);}}> @@ -91,7 +91,7 @@ const AddCommentDialog = inject("storeComments")(observer(props => {
${Device.android ? templateInitials : ''} -
${userInfo.name}
+
${GetUserName(userInfo.name)}
@@ -223,7 +223,7 @@ const EditCommentPopup = inject("storeComments")(observer(({storeComments, comme
{comment.userInitials}
}
-
{comment.userName}
+
{GetUserName(comment.userName)}
{comment.date}
@@ -260,7 +260,7 @@ const EditCommentDialog = inject("storeComments")(observer(({storeComments, comm
${Device.android ? templateInitials : ''}
-
${comment.userName}
+
${GetUserName(comment.userName)}
${comment.date}
@@ -352,7 +352,7 @@ const AddReplyPopup = inject("storeComments")(observer(({storeComments, userInfo {Device.android &&
{userInfo.initials}
} -
{userInfo.name}
+
{GetUserName(userInfo.name)}
{setText(event.target.value);}}> @@ -386,7 +386,7 @@ const AddReplyDialog = inject("storeComments")(observer(({storeComments, userInf
${Device.android ? templateInitials : ''} -
${userInfo.name}
+
${GetUserName(userInfo.name)}
@@ -479,7 +479,7 @@ const EditReplyPopup = inject("storeComments")(observer(({storeComments, comment
{reply.userInitials}
}
-
{reply.userName}
+
{GetUserName(reply.userName)}
{reply.date}
@@ -516,7 +516,7 @@ const EditReplyDialog = inject("storeComments")(observer(({storeComments, commen
${Device.android ? templateInitials : ''}
-
${reply.userName}
+
${GetUserName(reply.userName)}
${reply.date}
@@ -663,7 +663,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
{isAndroid &&
{comment.userInitials}
}
-
{comment.userName}
+
{GetUserName(comment.userName)}
{comment.date}
@@ -693,7 +693,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
{isAndroid &&
{reply.userInitials}
}
-
{reply.userName}
+
{GetUserName(reply.userName)}
{reply.date}
@@ -792,7 +792,7 @@ const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeC
{isAndroid &&
{comment.userInitials}
}
-
{comment.userName}
+
{GetUserName(comment.userName)}
{comment.date}
@@ -822,7 +822,7 @@ const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeC
{isAndroid &&
{reply.userInitials}
}
-
{reply.userName}
+
{GetUserName(reply.userName)}
{reply.date}
@@ -929,6 +929,12 @@ const ViewCurrentComments = props => { ) }; +const GetUserName = name => { + return ( + Common.Utils.String.htmlEncode(AscCommon.UserInfoParser.getParsedName(name)) + ) +}; + export { AddComment, EditComment, From 12c0492c90d42af31897f81568e8bee47acb97f4 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Fri, 2 Jul 2021 15:48:50 +0300 Subject: [PATCH 2/4] [mobile] Fix user name in comments --- .../lib/controller/collaboration/Comments.jsx | 25 ++++++++++++---- apps/common/mobile/lib/store/comments.js | 1 + .../lib/view/collaboration/Comments.jsx | 30 ++++++++----------- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/apps/common/mobile/lib/controller/collaboration/Comments.jsx b/apps/common/mobile/lib/controller/collaboration/Comments.jsx index 43cf13dfe..b9f9d9d5d 100644 --- a/apps/common/mobile/lib/controller/collaboration/Comments.jsx +++ b/apps/common/mobile/lib/controller/collaboration/Comments.jsx @@ -43,6 +43,11 @@ const dateToLocaleTimeString = (date) => { // MM/dd/yyyy hh:mm AM return (date.getMonth() + 1) + '/' + (date.getDate()) + '/' + date.getFullYear() + ' ' + format(date); }; +const parseUserName = name => { + return ( + Common.Utils.String.htmlEncode(AscCommon.UserInfoParser.getParsedName(name)) + ) +}; //end utils class CommentsController extends Component { @@ -123,10 +128,12 @@ class CommentsController extends Component { ((data.asc_getTime() === '') ? new Date() : new Date(stringUtcToLocalDate(data.asc_getTime()))); let user = this.usersStore.searchUserById(data.asc_getUserId()); + const name = data.asc_getUserName(); changeComment.comment = data.asc_getText(); changeComment.userId = data.asc_getUserId(); - changeComment.userName = data.asc_getUserName(); + changeComment.userName = name; + changeComment.parsedName = parseUserName(name); changeComment.userColor = (user) ? user.asc_getColor() : null; changeComment.resolved = data.asc_getSolved(); changeComment.quote = data.asc_getQuoteText(); @@ -146,15 +153,17 @@ class CommentsController extends Component { user = this.usersStore.searchUserById(data.asc_getReply(i).asc_getUserId()); const userName = data.asc_getReply(i).asc_getUserName(); + const parsedName = parseUserName(userName); replies.push({ ind: i, userId: data.asc_getReply(i).asc_getUserId(), userName: userName, + parsedName: parsedName, userColor: (user) ? user.asc_getColor() : null, date: dateToLocaleTimeString(dateReply), reply: data.asc_getReply(i).asc_getText(), time: dateReply.getTime(), - userInitials: this.usersStore.getInitials(userName), + userInitials: this.usersStore.getInitials(parsedName), editable: this.appOptions.canEditComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId), removable: this.appOptions.canDeleteComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId) }); @@ -172,10 +181,12 @@ class CommentsController extends Component { const user = this.usersStore.searchUserById(data.asc_getUserId()); const groupName = id.substr(0, id.lastIndexOf('_')+1).match(/^(doc|sheet[0-9_]+)_/); const userName = data.asc_getUserName(); + const parsedName = parseUserName(userName); const comment = { uid : id, userId : data.asc_getUserId(), userName : userName, + parsedName : parsedName, userColor : (user) ? user.asc_getColor() : null, date : dateToLocaleTimeString(date), quote : data.asc_getQuoteText(), @@ -185,7 +196,7 @@ class CommentsController extends Component { time : date.getTime(), replies : [], groupName : (groupName && groupName.length>1) ? groupName[1] : null, - userInitials : this.usersStore.getInitials(userName), + userInitials : this.usersStore.getInitials(parsedName), editable : this.appOptions.canEditComments || (data.asc_getUserId() === this.curUserId), removable : this.appOptions.canDeleteComments || (data.asc_getUserId() === this.curUserId) }; @@ -208,15 +219,17 @@ class CommentsController extends Component { ((data.asc_getReply(i).asc_getTime() === '') ? new Date() : new Date(stringUtcToLocalDate(data.asc_getReply(i).asc_getTime()))); const user = this.usersStore.searchUserById(data.asc_getReply(i).asc_getUserId()); const userName = data.asc_getReply(i).asc_getUserName(); + const parsedName = parseUserName(userName); replies.push({ ind : i, userId : data.asc_getReply(i).asc_getUserId(), userName : userName, + parsedName : parsedName, userColor : (user) ? user.asc_getColor() : null, date : dateToLocaleTimeString(date), reply : data.asc_getReply(i).asc_getText(), time : date.getTime(), - userInitials : this.usersStore.getInitials(userName), + userInitials : this.usersStore.getInitials(parsedName), editable : this.appOptions.canEditComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId), removable : this.appOptions.canDeleteComments || (data.asc_getReply(i).asc_getUserId() === this.curUserId) }); @@ -252,7 +265,7 @@ class AddCommentController extends Component { if (!this.currentUser) { this.currentUser = this.props.users.setCurrentUser(this.props.storeAppOptions.user.id); } - const name = this.currentUser.asc_getUserName(); + const name = parseUserName(this.currentUser.asc_getUserName()); return { name: name, initials: this.props.users.getInitials(name), @@ -296,7 +309,7 @@ class EditCommentController extends Component { } getUserInfo () { this.currentUser = this.props.users.currentUser; - const name = this.currentUser.asc_getUserName(); + const name = parseUserName(this.currentUser.asc_getUserName()); return { name: name, initials: this.props.users.getInitials(name), diff --git a/apps/common/mobile/lib/store/comments.js b/apps/common/mobile/lib/store/comments.js index 6d5fc05cc..5fea1e057 100644 --- a/apps/common/mobile/lib/store/comments.js +++ b/apps/common/mobile/lib/store/comments.js @@ -70,6 +70,7 @@ export class storeComments { comment.comment = changeComment.comment; comment.userId = changeComment.userId; comment.userName = changeComment.userName; + comment.parsedName = changeComment.parsedName; comment.userColor = changeComment.userColor; comment.resolved = changeComment.resolved; comment.quote = changeComment.quote; diff --git a/apps/common/mobile/lib/view/collaboration/Comments.jsx b/apps/common/mobile/lib/view/collaboration/Comments.jsx index 23be9fae5..de88658f7 100644 --- a/apps/common/mobile/lib/view/collaboration/Comments.jsx +++ b/apps/common/mobile/lib/view/collaboration/Comments.jsx @@ -56,7 +56,7 @@ const AddCommentPopup = inject("storeComments")(observer(props => { {Device.android &&
{userInfo.initials}
} -
{GetUserName(userInfo.name)}
+
{userInfo.name}
{setText(event.target.value);}}> @@ -91,7 +91,7 @@ const AddCommentDialog = inject("storeComments")(observer(props => {
${Device.android ? templateInitials : ''} -
${GetUserName(userInfo.name)}
+
${userInfo.name}
@@ -223,7 +223,7 @@ const EditCommentPopup = inject("storeComments")(observer(({storeComments, comme
{comment.userInitials}
}
-
{GetUserName(comment.userName)}
+
{comment.parsedName}
{comment.date}
@@ -260,7 +260,7 @@ const EditCommentDialog = inject("storeComments")(observer(({storeComments, comm
${Device.android ? templateInitials : ''}
-
${GetUserName(comment.userName)}
+
${comment.parsedName}
${comment.date}
@@ -352,7 +352,7 @@ const AddReplyPopup = inject("storeComments")(observer(({storeComments, userInfo {Device.android &&
{userInfo.initials}
} -
{GetUserName(userInfo.name)}
+
{userInfo.name}
{setText(event.target.value);}}> @@ -386,7 +386,7 @@ const AddReplyDialog = inject("storeComments")(observer(({storeComments, userInf
${Device.android ? templateInitials : ''} -
${GetUserName(userInfo.name)}
+
${userInfo.name}
@@ -479,7 +479,7 @@ const EditReplyPopup = inject("storeComments")(observer(({storeComments, comment
{reply.userInitials}
}
-
{GetUserName(reply.userName)}
+
{reply.parsedName}
{reply.date}
@@ -516,7 +516,7 @@ const EditReplyDialog = inject("storeComments")(observer(({storeComments, commen
${Device.android ? templateInitials : ''}
-
${GetUserName(reply.userName)}
+
${reply.parsedName}
${reply.date}
@@ -663,7 +663,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
{isAndroid &&
{comment.userInitials}
}
-
{GetUserName(comment.userName)}
+
{comment.parsedName}
{comment.date}
@@ -693,7 +693,7 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
{isAndroid &&
{reply.userInitials}
}
-
{GetUserName(reply.userName)}
+
{reply.parsedName}
{reply.date}
@@ -792,7 +792,7 @@ const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeC
{isAndroid &&
{comment.userInitials}
}
-
{GetUserName(comment.userName)}
+
{comment.parsedName}
{comment.date}
@@ -822,7 +822,7 @@ const CommentList = inject("storeComments", "storeAppOptions")(observer(({storeC
{isAndroid &&
{reply.userInitials}
}
-
{GetUserName(reply.userName)}
+
{reply.parsedName}
{reply.date}
@@ -929,12 +929,6 @@ const ViewCurrentComments = props => { ) }; -const GetUserName = name => { - return ( - Common.Utils.String.htmlEncode(AscCommon.UserInfoParser.getParsedName(name)) - ) -}; - export { AddComment, EditComment, From b154777f5a37ef91f9dafba991ba50ee5f1cbd12 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Fri, 2 Jul 2021 17:49:53 +0300 Subject: [PATCH 3/4] [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]!==')') { From 6e475b9e90325872d74982683e4c37296f1718aa Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Fri, 2 Jul 2021 19:20:59 +0300 Subject: [PATCH 4/4] [mobile] Fix context menu --- apps/common/mobile/lib/controller/ContextMenu.jsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/common/mobile/lib/controller/ContextMenu.jsx b/apps/common/mobile/lib/controller/ContextMenu.jsx index ef6f5f897..c5b580e22 100644 --- a/apps/common/mobile/lib/controller/ContextMenu.jsx +++ b/apps/common/mobile/lib/controller/ContextMenu.jsx @@ -18,6 +18,7 @@ class ContextMenuController extends Component { extraItems: [] }; + this.fastCoAuthTips = []; this.onMenuItemClick = this.onMenuItemClick.bind(this); this.onMenuClosed = this.onMenuClosed.bind(this); this.onActionClosed = this.onActionClosed.bind(this); @@ -161,9 +162,6 @@ class ContextMenuController extends Component { /** coauthoring begin **/ const tipHeight = 20; - if (!this.fastCoAuthTips) { - this.fastCoAuthTips = []; - } let src; for (let i=0; i