Save user id for anonymous user (when user.id is undefined).
[Mobile] Fix loading name for guest user
This commit is contained in:
parent
5d4105f2fd
commit
d99ad6b1fc
|
@ -741,9 +741,10 @@ Common.Utils.applyCustomizationPlugins = function(plugins) {
|
|||
});
|
||||
};
|
||||
|
||||
Common.Utils.fillUserInfo = function(info, lang, defname) {
|
||||
Common.Utils.fillUserInfo = function(info, lang, defname, defid) {
|
||||
var _user = info || {};
|
||||
!_user.id && (_user.id = ('uid-' + Date.now()));
|
||||
_user.anonymous = !_user.id;
|
||||
!_user.id && (_user.id = defid);
|
||||
_user.fullname = !_user.name ? defname : _user.name;
|
||||
_user.group && (_user.fullname = (_user.group).toString() + AscCommon.UserInfoParser.getSeparator() + _user.fullname);
|
||||
_user.guest = !_user.name;
|
||||
|
|
|
@ -361,7 +361,10 @@ define([
|
|||
Common.Utils.InternalSettings.set("save-guest-username", !!value);
|
||||
}
|
||||
this.editorConfig.user =
|
||||
this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, value ? (value + ' (' + this.appOptions.guestName + ')' ) : this.textAnonymous);
|
||||
this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, value ? (value + ' (' + this.appOptions.guestName + ')' ) : this.textAnonymous,
|
||||
Common.localStorage.getItem("guest-id") || ('uid-' + Date.now()));
|
||||
this.appOptions.user.anonymous && Common.localStorage.setItem("guest-id", this.appOptions.user.id);
|
||||
|
||||
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
|
||||
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl);
|
||||
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
|
||||
|
@ -434,6 +437,7 @@ define([
|
|||
var _user = new Asc.asc_CUserInfo();
|
||||
_user.put_Id(this.appOptions.user.id);
|
||||
_user.put_FullName(this.appOptions.user.fullname);
|
||||
// _user.put_isAnonymous(!!this.appOptions.user.anonymous);
|
||||
|
||||
docInfo = new Asc.asc_CDocInfo();
|
||||
docInfo.put_Id(data.doc.key);
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
"List Paragraph": "List Paragraph",
|
||||
"footnote text": "Footnote Text"
|
||||
},
|
||||
"textGuest": "Guest",
|
||||
"textAnonymous": "Anonymous",
|
||||
"leavePageText": "You have unsaved changes in this document. Click 'Stay on this Page' to await the autosave of the document. Click 'Leave this Page' to discard all the unsaved changes.",
|
||||
"titleLicenseExp": "License expired",
|
||||
"warnLicenseExp": "Your license has expired. Please update your license and refresh the page.",
|
||||
|
|
|
@ -74,12 +74,14 @@ class MainController extends Component {
|
|||
};
|
||||
|
||||
const loadConfig = data => {
|
||||
const _t = this._t;
|
||||
|
||||
EditorUIController.isSupportEditFeature();
|
||||
console.log('load config');
|
||||
|
||||
this.editorConfig = Object.assign({}, this.editorConfig, data.config);
|
||||
|
||||
this.props.storeAppOptions.setConfigOptions(this.editorConfig);
|
||||
this.props.storeAppOptions.setConfigOptions(this.editorConfig, _t);
|
||||
|
||||
this.editorConfig.lang && this.api.asc_setLocale(this.editorConfig.lang);
|
||||
|
||||
|
@ -109,6 +111,7 @@ class MainController extends Component {
|
|||
const _user = new Asc.asc_CUserInfo();
|
||||
_user.put_Id(_userOptions.id);
|
||||
_user.put_FullName(_userOptions.fullname);
|
||||
// _user.put_isAnonymous(_userOptions.anonymous);
|
||||
|
||||
docInfo = new Asc.asc_CDocInfo();
|
||||
docInfo.put_Id(data.doc.key);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import {makeObservable, action, observable} from 'mobx';
|
||||
import { LocalStorage } from '../../../../common/mobile/utils/LocalStorage';
|
||||
|
||||
export class storeAppOptions {
|
||||
constructor() {
|
||||
|
@ -48,9 +49,19 @@ export class storeAppOptions {
|
|||
}
|
||||
|
||||
config = {};
|
||||
setConfigOptions (config) {
|
||||
setConfigOptions (config, _t) {
|
||||
this.config = config;
|
||||
this.user = Common.Utils.fillUserInfo(config.user, config.lang, "Local.User"/*me.textAnonymous*/);
|
||||
this.customization = config.customization;
|
||||
this.canRenameAnonymous = !((typeof (this.customization) == 'object') && (typeof (this.customization.anonymous) == 'object') && (this.customization.anonymous.request===false));
|
||||
this.guestName = (typeof (this.customization) == 'object') && (typeof (this.customization.anonymous) == 'object') &&
|
||||
(typeof (this.customization.anonymous.label) == 'string') && this.customization.anonymous.label.trim()!=='' ?
|
||||
Common.Utils.String.htmlEncode(this.customization.anonymous.label) : _t.textGuest;
|
||||
|
||||
const value = this.canRenameAnonymous ? LocalStorage.getItem("guest-username") : null;
|
||||
this.user = Common.Utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + this.guestName + ')' ) : _t.textAnonymous, LocalStorage.getItem("guest-id") || ('uid-' + Date.now()));
|
||||
this.user.anonymous && LocalStorage.setItem("guest-id", this.user.id);
|
||||
|
||||
config.user = this.user;
|
||||
this.isDesktopApp = config.targetApp == 'desktop';
|
||||
this.canCreateNew = !!config.createUrl && !this.isDesktopApp;
|
||||
this.canOpenRecent = config.recent !== undefined && !this.isDesktopApp;
|
||||
|
@ -64,7 +75,6 @@ export class storeAppOptions {
|
|||
this.mergeFolderUrl = config.mergeFolderUrl;
|
||||
this.canAnalytics = false;
|
||||
this.canRequestClose = config.canRequestClose;
|
||||
this.customization = config.customization;
|
||||
this.canBackToFolder = (config.canBackToFolder!==false) && (typeof (config.customization) == 'object') && (typeof (config.customization.goback) == 'object')
|
||||
&& (!!(config.customization.goback.url) || config.customization.goback.requestClose && this.canRequestClose);
|
||||
this.canBack = this.canBackToFolder === true;
|
||||
|
|
|
@ -322,7 +322,10 @@ define([
|
|||
Common.Utils.InternalSettings.set("save-guest-username", !!value);
|
||||
}
|
||||
this.editorConfig.user =
|
||||
this.appOptions.user = Common.Utils.fillUserInfo(data.config.user, this.editorConfig.lang, value ? (value + ' (' + this.appOptions.guestName + ')' ) : this.textAnonymous);
|
||||
this.appOptions.user = Common.Utils.fillUserInfo(data.config.user, this.editorConfig.lang, value ? (value + ' (' + this.appOptions.guestName + ')' ) : this.textAnonymous,
|
||||
Common.localStorage.getItem("guest-id") || ('uid-' + Date.now()));
|
||||
this.appOptions.user.anonymous && Common.localStorage.setItem("guest-id", this.appOptions.user.id);
|
||||
|
||||
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
|
||||
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl);
|
||||
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
|
||||
|
@ -393,6 +396,7 @@ define([
|
|||
var _user = new Asc.asc_CUserInfo();
|
||||
_user.put_Id(this.appOptions.user.id);
|
||||
_user.put_FullName(this.appOptions.user.fullname);
|
||||
// _user.put_isAnonymous(!!this.appOptions.user.anonymous);
|
||||
|
||||
docInfo = new Asc.asc_CDocInfo();
|
||||
docInfo.put_Id(data.doc.key);
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
"Table": "Table",
|
||||
"Slide title": "Slide title"
|
||||
},
|
||||
"textGuest": "Guest",
|
||||
"textAnonymous": "Anonymous",
|
||||
"closeButtonText": "Close File",
|
||||
"advDRMOptions": "Protected File",
|
||||
"advDRMPassword": "Password",
|
||||
|
|
|
@ -70,13 +70,15 @@ class MainController extends Component {
|
|||
};
|
||||
|
||||
const loadConfig = data => {
|
||||
const _t = this._t;
|
||||
|
||||
EditorUIController.isSupportEditFeature();
|
||||
|
||||
console.log('load config');
|
||||
|
||||
this.editorConfig = Object.assign({}, this.editorConfig, data.config);
|
||||
|
||||
this.props.storeAppOptions.setConfigOptions(this.editorConfig);
|
||||
this.props.storeAppOptions.setConfigOptions(this.editorConfig, _t);
|
||||
|
||||
this.editorConfig.lang && this.api.asc_setLocale(this.editorConfig.lang);
|
||||
|
||||
|
@ -104,6 +106,7 @@ class MainController extends Component {
|
|||
const _userOptions = this.props.storeAppOptions.user;
|
||||
_user.put_Id(_userOptions.id);
|
||||
_user.put_FullName(_userOptions.fullname);
|
||||
// _user.put_isAnonymous(_userOptions.anonymous);
|
||||
|
||||
docInfo = new Asc.asc_CDocInfo();
|
||||
docInfo.put_Id(data.doc.key);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import {action, observable, makeObservable} from 'mobx';
|
||||
import { LocalStorage } from '../../../../common/mobile/utils/LocalStorage';
|
||||
|
||||
export class storeAppOptions {
|
||||
constructor() {
|
||||
|
@ -30,9 +31,19 @@ export class storeAppOptions {
|
|||
this.isDocReady = value;
|
||||
}
|
||||
|
||||
setConfigOptions (config) {
|
||||
setConfigOptions (config, _t) {
|
||||
this.config = config;
|
||||
this.user = Common.Utils.fillUserInfo(config.user, config.lang, "Local.User"/*me.textAnonymous*/);
|
||||
this.customization = config.customization;
|
||||
this.canRenameAnonymous = !((typeof (this.customization) == 'object') && (typeof (this.customization.anonymous) == 'object') && (this.customization.anonymous.request===false));
|
||||
this.guestName = (typeof (this.customization) == 'object') && (typeof (this.customization.anonymous) == 'object') &&
|
||||
(typeof (this.customization.anonymous.label) == 'string') && this.customization.anonymous.label.trim()!=='' ?
|
||||
Common.Utils.String.htmlEncode(this.customization.anonymous.label) : _t.textGuest;
|
||||
|
||||
const value = this.canRenameAnonymous ? LocalStorage.getItem("guest-username") : null;
|
||||
this.user = Common.Utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + this.guestName + ')' ) : _t.textAnonymous, LocalStorage.getItem("guest-id") || ('uid-' + Date.now()));
|
||||
this.user.anonymous && LocalStorage.setItem("guest-id", this.user.id);
|
||||
|
||||
config.user = this.user;
|
||||
this.isDesktopApp = config.targetApp == 'desktop';
|
||||
this.canCreateNew = !!config.createUrl && !this.isDesktopApp;
|
||||
this.canOpenRecent = config.recent !== undefined && !this.isDesktopApp;
|
||||
|
@ -46,7 +57,6 @@ export class storeAppOptions {
|
|||
this.mergeFolderUrl = config.mergeFolderUrl;
|
||||
this.canAnalytics = false;
|
||||
this.canRequestClose = config.canRequestClose;
|
||||
this.customization = config.customization;
|
||||
this.canBackToFolder = (config.canBackToFolder!==false) && (typeof (config.customization) == 'object') && (typeof (config.customization.goback) == 'object')
|
||||
&& (!!(config.customization.goback.url) || config.customization.goback.requestClose && this.canRequestClose);
|
||||
this.canBack = this.canBackToFolder === true;
|
||||
|
|
|
@ -356,7 +356,10 @@ define([
|
|||
Common.Utils.InternalSettings.set("save-guest-username", !!value);
|
||||
}
|
||||
this.editorConfig.user =
|
||||
this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, value ? (value + ' (' + this.appOptions.guestName + ')' ) : this.textAnonymous);
|
||||
this.appOptions.user = Common.Utils.fillUserInfo(this.editorConfig.user, this.editorConfig.lang, value ? (value + ' (' + this.appOptions.guestName + ')' ) : this.textAnonymous,
|
||||
Common.localStorage.getItem("guest-id") || ('uid-' + Date.now()));
|
||||
this.appOptions.user.anonymous && Common.localStorage.setItem("guest-id", this.appOptions.user.id);
|
||||
|
||||
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
|
||||
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl);
|
||||
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
|
||||
|
@ -458,6 +461,7 @@ define([
|
|||
var _user = new Asc.asc_CUserInfo();
|
||||
_user.put_Id(this.appOptions.user.id);
|
||||
_user.put_FullName(this.appOptions.user.fullname);
|
||||
// _user.put_isAnonymous(!!this.appOptions.user.anonymous);
|
||||
|
||||
docInfo = new Asc.asc_CDocInfo();
|
||||
docInfo.put_Id(data.doc.key);
|
||||
|
|
|
@ -143,6 +143,7 @@ class MainController extends Component {
|
|||
|
||||
_user.put_Id(_userOptions.id);
|
||||
_user.put_FullName(_userOptions.fullname);
|
||||
// _user.put_isAnonymous(_userOptions.anonymous);
|
||||
|
||||
docInfo = new Asc.asc_CDocInfo();
|
||||
docInfo.put_Id(data.doc.key);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import {action, observable, makeObservable} from 'mobx';
|
||||
import { LocalStorage } from '../../../../common/mobile/utils/LocalStorage';
|
||||
|
||||
export class storeAppOptions {
|
||||
constructor() {
|
||||
|
@ -38,9 +39,10 @@ export class storeAppOptions {
|
|||
(typeof (this.customization.anonymous.label) == 'string') && this.customization.anonymous.label.trim()!=='' ?
|
||||
Common.Utils.String.htmlEncode(this.customization.anonymous.label) : _t.textGuest;
|
||||
|
||||
const value = this.canRenameAnonymous ? Common.localStorage.getItem("guest-username") : null;
|
||||
this.user = Common.Utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + this.guestName + ')' ) : _t.textAnonymous);
|
||||
|
||||
const value = this.canRenameAnonymous ? LocalStorage.getItem("guest-username") : null;
|
||||
this.user = Common.Utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + this.guestName + ')' ) : _t.textAnonymous, LocalStorage.getItem("guest-id") || ('uid-' + Date.now()));
|
||||
this.user.anonymous && LocalStorage.setItem("guest-id", this.user.id);
|
||||
|
||||
config.user = this.user;
|
||||
this.isDesktopApp = config.targetApp == 'desktop';
|
||||
this.canCreateNew = !!config.createUrl && !this.isDesktopApp;
|
||||
|
@ -58,7 +60,6 @@ export class storeAppOptions {
|
|||
this.mergeFolderUrl = config.mergeFolderUrl;
|
||||
this.canAnalytics = false;
|
||||
this.canRequestClose = config.canRequestClose;
|
||||
this.customization = config.customization;
|
||||
this.canBackToFolder = (config.canBackToFolder!==false) && (typeof (config.customization) == 'object') && (typeof (config.customization.goback) == 'object')
|
||||
&& (!!(config.customization.goback.url) || config.customization.goback.requestClose && this.canRequestClose);
|
||||
this.canBack = this.canBackToFolder === true;
|
||||
|
|
Loading…
Reference in a new issue