[mobile] Fix user name in comments (2)

This commit is contained in:
JuliaSvinareva 2021-07-02 17:49:53 +03:00
parent 12c0492c90
commit b154777f5a
4 changed files with 14 additions and 12 deletions

View file

@ -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()
};

View file

@ -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;

View file

@ -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;

View file

@ -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]!==')') {