Skip to content

Commit

Permalink
Merge pull request #2857 from ONLYOFFICE/fix/bugfix
Browse files Browse the repository at this point in the history
Fix/bugfix
  • Loading branch information
JuliaRadzhabova authored Feb 22, 2024
2 parents e72340c + 6552fae commit 3740ba4
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 49 deletions.
12 changes: 6 additions & 6 deletions apps/common/main/lib/controller/Comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ define([
comment.set('initials', Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(data.asc_getUserName())));
comment.set('parsedName', AscCommon.UserInfoParser.getParsedName(data.asc_getUserName()));
comment.set('parsedGroups', AscCommon.UserInfoParser.getParsedGroups(data.asc_getUserName()));
comment.set('usercolor', (user) ? user.get('color') : null);
comment.set('usercolor', (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(userid || data.asc_getUserName()));
comment.set('avatar', avatar);
comment.set('resolved', data.asc_getSolved());
comment.set('quote', data.asc_getQuoteText());
Expand Down Expand Up @@ -890,7 +890,7 @@ define([
username : data.asc_getReply(i).asc_getUserName(),
initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(data.asc_getReply(i).asc_getUserName())),
parsedName : AscCommon.UserInfoParser.getParsedName(data.asc_getReply(i).asc_getUserName()),
usercolor : (user) ? user.get('color') : null,
usercolor : (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(userid || data.asc_getReply(i).asc_getUserName()),
avatar : avatar,
date : t.dateToLocaleTimeString(dateReply),
reply : data.asc_getReply(i).asc_getText(),
Expand Down Expand Up @@ -1300,7 +1300,7 @@ define([
var users = this.userCollection,
hasGroup = false,
updateCommentData = function(comment, user, isNotReply) {
var color = (user) ? user.get('color') : null,
var color = (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(comment.get('userid')),
needrender = false;
if (color !== comment.get('usercolor')) {
needrender = true;
Expand Down Expand Up @@ -1395,7 +1395,7 @@ define([
initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(data.asc_getUserName())),
parsedName : AscCommon.UserInfoParser.getParsedName(data.asc_getUserName()),
parsedGroups : AscCommon.UserInfoParser.getParsedGroups(data.asc_getUserName()),
usercolor : (user) ? user.get('color') : null,
usercolor : (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(userid || data.asc_getUserName()),
avatar : avatar,
date : this.dateToLocaleTimeString(date),
quote : data.asc_getQuoteText(),
Expand Down Expand Up @@ -1456,7 +1456,7 @@ define([
username : data.asc_getReply(i).asc_getUserName(),
initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(data.asc_getReply(i).asc_getUserName())),
parsedName : AscCommon.UserInfoParser.getParsedName(data.asc_getReply(i).asc_getUserName()),
usercolor : (user) ? user.get('color') : null,
usercolor : (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(userid || data.asc_getReply(i).asc_getUserName()),
avatar : avatar,
date : this.dateToLocaleTimeString(date),
reply : data.asc_getReply(i).asc_getText(),
Expand Down Expand Up @@ -1501,7 +1501,7 @@ define([
avatar: Common.UI.ExternalUsers.getImage(this.currentUserId),
initials: Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(AscCommon.UserInfoParser.getCurrentName())),
parsedName: AscCommon.UserInfoParser.getParsedName(AscCommon.UserInfoParser.getCurrentName()),
usercolor: (user) ? user.get('color') : null,
usercolor: (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(this.currentUserId),
editTextInPopover: true,
showReplyInPopover: false,
hideAddReply: true,
Expand Down
20 changes: 16 additions & 4 deletions apps/common/main/lib/controller/ExternalUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ Common.UI.ExternalUsers = new( function() {
isUsersLoading = false,
externalUsersInfo = [],
isUsersInfoLoading = false,
stackUsersInfoResponse = [];
stackUsersInfoResponse = [],
api,
userColors = [];

var _get = function(type, ids) {
if (type==='info') {
Expand Down Expand Up @@ -114,9 +116,9 @@ Common.UI.ExternalUsers = new( function() {
_onUsersInfo(stackUsersInfoResponse.shift());
};

var _init = function(canRequestUsers) {
var _init = function(canRequestUsers, _api) {
Common.Gateway.on('setusers', _onUsersInfo);

api = _api;
if (!canRequestUsers) return;

Common.Gateway.on('setusers', function(data) {
Expand All @@ -137,10 +139,20 @@ Common.UI.ExternalUsers = new( function() {
});
};

var _getColor = function(id, intValue) {
if (!userColors[id]) {
var color = api.asc_getUserColorById(id);
userColors[id] = ["#"+("000000"+color.toString(16)).substr(-6), color];
}

return intValue ? userColors[id][1] : userColors[id][0];
};

return {
init: _init,
get: _get,
getImage: _getImage,
setImage: _setImage
setImage: _setImage,
getColor: _getColor
}
})();
4 changes: 2 additions & 2 deletions apps/common/main/lib/controller/ReviewChanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ define([
uid : Common.UI.getId(),
userid : item.get_UserId(),
username : item.get_UserName(),
usercolor : (user) ? user.get('color') : null,
usercolor : (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(item.get_UserId() || item.get_UserName()),
initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(item.get_UserName())),
avatar : avatar,
date : me.dateToLocaleTimeString(date),
Expand Down Expand Up @@ -1091,7 +1091,7 @@ define([
var users = this.userCollection;
this.popoverChanges && this.popoverChanges.each(function (model) {
var user = users.findOriginalUser(model.get('userid'));
model.set('usercolor', (user) ? user.get('color') : null);
model.set('usercolor', (user) ? user.get('color') : Common.UI.ExternalUsers.getColor(model.get('userid')));
user && user.get('avatar') && model.set('avatar', user.get('avatar'));
});
},
Expand Down
2 changes: 1 addition & 1 deletion apps/common/main/lib/view/Chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ define([
var user = this.storeUsers.findOriginalUser(m.get('userid')),
avatar = Common.UI.ExternalUsers.getImage(m.get('userid'));
m.set({
usercolor : user ? user.get('color') : null,
usercolor : user ? user.get('color') : Common.UI.ExternalUsers.getColor(m.get('userid')),
avatar : avatar,
initials : user ? user.get('initials') : Common.Utils.getUserInitials(m.get('parsedName')),
message : this._pickLink(m.get('message'))
Expand Down
18 changes: 9 additions & 9 deletions apps/documenteditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,11 +718,12 @@ define([
docIdPrev = (ver>0 && versions[ver-1]) ? versions[ver-1].key : version.key + '0';
user = usersStore.findUser(version.user.id);
if (!user) {
var color = Common.UI.ExternalUsers.getColor(version.user.id || version.user.name || this.textAnonymous, true);
user = new Common.Models.User({
id : version.user.id,
username : version.user.name || this.textAnonymous,
colorval : Asc.c_oAscArrUserColors[usersCnt],
color : this.generateUserColor(Asc.c_oAscArrUserColors[usersCnt++])
colorval : color,
color : this.generateUserColor(color)
});
usersStore.add(user);
}
Expand Down Expand Up @@ -770,11 +771,12 @@ define([

user = usersStore.findUser(change.user.id);
if (!user) {
var color = Common.UI.ExternalUsers.getColor(change.user.id || change.user.name || this.textAnonymous, true);
user = new Common.Models.User({
id : change.user.id,
username : change.user.name || this.textAnonymous,
colorval : Asc.c_oAscArrUserColors[usersCnt],
color : this.generateUserColor(Asc.c_oAscArrUserColors[usersCnt++])
colorval : color,
color : this.generateUserColor(color)
});
usersStore.add(user);
}
Expand Down Expand Up @@ -1662,7 +1664,7 @@ define([
this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions, this.api);
this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout, this.appOptions.canBrandingExt);
this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features, this.appOptions.canBrandingExt);
Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers);
Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers, this.api);
this.appOptions.user.image ? Common.UI.ExternalUsers.setImage(this.appOptions.user.id, this.appOptions.user.image) : Common.UI.ExternalUsers.get('info', this.appOptions.user.id);

if (this.appOptions.canComments)
Expand Down Expand Up @@ -1714,10 +1716,8 @@ define([
}
}
fastCoauth = (value===null || parseInt(value) == 1);

value = Common.localStorage.getItem((fastCoauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict");
if (value == null) value = fastCoauth ? 'none' : 'last';
Common.Utils.InternalSettings.set((fastCoauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict", value);
Common.Utils.InternalSettings.set("de-settings-showchanges-fast", Common.localStorage.getItem("de-settings-showchanges-fast") || 'none');
Common.Utils.InternalSettings.set("de-settings-showchanges-strict", Common.localStorage.getItem("de-settings-showchanges-strict") || 'last');
} else if (!this.appOptions.isEdit && this.appOptions.isRestrictedEdit) {
fastCoauth = true;
} else if (this.appOptions.canLiveView && !this.appOptions.isOffline) { // viewer
Expand Down
12 changes: 8 additions & 4 deletions apps/documenteditor/main/app/view/FileMenuPanels.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,11 @@ define([
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.rbCoAuthModeFast.on('change', function(){
me.chAutosave.setValue(1);
me.onChangeCoAuthMode(1);
this.rbCoAuthModeFast.on('change', function(field, newValue, eOpts){
if (newValue) {
me.chAutosave.setValue(1);
me.onChangeCoAuthMode(1);
}
});
this.rbCoAuthModeFast.$el.parent().on('click', function (){me.rbCoAuthModeFast.setValue(true);});

Expand All @@ -624,7 +626,9 @@ define([
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.rbCoAuthModeStrict.on('change', _.bind(this.onChangeCoAuthMode, this,0));
this.rbCoAuthModeStrict.on('change', function(field, newValue, eOpts){
newValue && me.onChangeCoAuthMode(0);
});
this.rbCoAuthModeStrict.$el.parent().on('click', function (){me.rbCoAuthModeStrict.setValue(true);});

this.rbChangesBallons = new Common.UI.RadioBox({
Expand Down
8 changes: 3 additions & 5 deletions apps/pdfeditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ define([
this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions, this.api);
this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout, this.appOptions.canBrandingExt);
this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features, this.appOptions.canBrandingExt);
Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers);
Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers, this.api);
this.appOptions.user.image ? Common.UI.ExternalUsers.setImage(this.appOptions.user.id, this.appOptions.user.image) : Common.UI.ExternalUsers.get('info', this.appOptions.user.id);

if (this.appOptions.canComments)
Expand Down Expand Up @@ -1320,10 +1320,8 @@ define([
}
}
fastCoauth = (value===null || parseInt(value) == 1);

value = Common.localStorage.getItem((fastCoauth) ? "pdfe-settings-showchanges-fast" : "pdfe-settings-showchanges-strict");
if (value == null) value = fastCoauth ? 'none' : 'last';
Common.Utils.InternalSettings.set((fastCoauth) ? "pdfe-settings-showchanges-fast" : "pdfe-settings-showchanges-strict", value);
Common.Utils.InternalSettings.set("pdfe-settings-showchanges-fast", Common.localStorage.getItem("pdfe-settings-showchanges-fast") || 'none');
Common.Utils.InternalSettings.set("pdfe-settings-showchanges-strict", Common.localStorage.getItem("pdfe-settings-showchanges-strict") || 'last');
} else {
fastCoauth = false;
autosave = 0;
Expand Down
12 changes: 8 additions & 4 deletions apps/pdfeditor/main/app/view/FileMenuPanels.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,11 @@ define([
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.rbCoAuthModeFast.on('change', function(){
me.chAutosave.setValue(1);
me.onChangeCoAuthMode(1);
this.rbCoAuthModeFast.on('change', function(field, newValue, eOpts){
if (newValue) {
me.chAutosave.setValue(1);
me.onChangeCoAuthMode(1);
}
});
this.rbCoAuthModeFast.$el.parent().on('click', function (){me.rbCoAuthModeFast.setValue(true);});

Expand All @@ -507,7 +509,9 @@ define([
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.rbCoAuthModeStrict.on('change', _.bind(this.onChangeCoAuthMode, this,0));
this.rbCoAuthModeStrict.on('change', function(field, newValue, eOpts){
newValue && me.onChangeCoAuthMode(0);
});
this.rbCoAuthModeStrict.$el.parent().on('click', function (){me.rbCoAuthModeStrict.setValue(true);});

this.rbShowChangesNone = new Common.UI.RadioBox({
Expand Down
12 changes: 7 additions & 5 deletions apps/presentationeditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ define([
this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions);
this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout, this.appOptions.canBrandingExt);
this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features, this.appOptions.canBrandingExt);
Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers);
Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers, this.api);
this.appOptions.user.image ? Common.UI.ExternalUsers.setImage(this.appOptions.user.id, this.appOptions.user.image) : Common.UI.ExternalUsers.get('info', this.appOptions.user.id);

// change = true by default in editor
Expand Down Expand Up @@ -2649,11 +2649,12 @@ define([
docIdPrev = (ver>0 && versions[ver-1]) ? versions[ver-1].key : version.key + '0';
user = usersStore.findUser(version.user.id);
if (!user) {
var color = Common.UI.ExternalUsers.getColor(version.user.id || version.user.name || this.textAnonymous, true);
user = new Common.Models.User({
id : version.user.id,
username : version.user.name,
colorval : Asc.c_oAscArrUserColors[usersCnt],
color : this.generateUserColor(Asc.c_oAscArrUserColors[usersCnt++])
colorval : color,
color : this.generateUserColor(color)
});
usersStore.add(user);
}
Expand Down Expand Up @@ -2701,11 +2702,12 @@ define([

user = usersStore.findUser(change.user.id);
if (!user) {
var color = Common.UI.ExternalUsers.getColor(change.user.id || change.user.name || this.textAnonymous, true);
user = new Common.Models.User({
id : change.user.id,
username : change.user.name,
colorval : Asc.c_oAscArrUserColors[usersCnt],
color : this.generateUserColor(Asc.c_oAscArrUserColors[usersCnt++])
colorval : color,
color : this.generateUserColor(color)
});
usersStore.add(user);
}
Expand Down
4 changes: 2 additions & 2 deletions apps/presentationeditor/main/app/view/FileMenuPanels.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ define([
dataHint : '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
}).on('change', function () {
me.chAutosave.setValue(1);
}).on('change', function (field, newValue, eOpts) {
newValue && me.chAutosave.setValue(1);
});
this.rbCoAuthModeFast.$el.parent().on('click', function (){me.rbCoAuthModeFast.setValue(true);});

Expand Down
Loading

0 comments on commit 3740ba4

Please sign in to comment.