From 045c00b4ff635c903bb929c550148b5a22d76194 Mon Sep 17 00:00:00 2001 From: Artem Tarasov Date: Tue, 26 Jul 2022 10:56:25 +0300 Subject: [PATCH] Web: Common/Doceditor: fixed name of init state of editor --- packages/asc-web-common/constants/index.js | 2 +- packages/asc-web-common/store/SettingsStore.js | 16 ++++++++-------- packages/asc-web-common/store/UserStore.js | 5 ++--- web/ASC.Web.Editor/src/client/bootstrap.js | 3 +-- web/ASC.Web.Editor/src/server/lib/template.js | 7 ++++--- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/packages/asc-web-common/constants/index.js b/packages/asc-web-common/constants/index.js index c822233e04..14f635ff5f 100644 --- a/packages/asc-web-common/constants/index.js +++ b/packages/asc-web-common/constants/index.js @@ -1,6 +1,6 @@ export const LANGUAGE = "language"; export const ARTICLE_PINNED_KEY = "asc_article_pinned_key"; -export const EDITOR_STATE_NAME = "__ASC_INITIAL_EDITOR_STATE__"; + /** * Enum for employee activation status. * @readonly diff --git a/packages/asc-web-common/store/SettingsStore.js b/packages/asc-web-common/store/SettingsStore.js index e766842dd8..8186635da0 100644 --- a/packages/asc-web-common/store/SettingsStore.js +++ b/packages/asc-web-common/store/SettingsStore.js @@ -1,6 +1,6 @@ import { makeAutoObservable } from "mobx"; import api from "../api"; -import { LANGUAGE, TenantStatus, EDITOR_STATE_NAME } from "../constants"; +import { LANGUAGE, TenantStatus } from "../constants"; import { combineUrl } from "../utils"; import FirebaseHelper from "../utils/firebase"; import { AppServerConfig, ThemeKeys } from "../constants"; @@ -175,8 +175,8 @@ class SettingsStore { getSettings = async () => { let newSettings = null; - if (window[`${EDITOR_STATE_NAME}`]?.portalSettings) - newSettings = window[`${EDITOR_STATE_NAME}`].portalSettings; + if (window?.__ASC_INITIAL_EDITOR_STATE__?.portalSettings) + newSettings = window.__ASC_INITIAL_EDITOR_STATE__.portalSettings; else newSettings = await api.settings.getSettings(); if (window["AscDesktopEditor"] !== undefined || this.personal) { @@ -218,9 +218,9 @@ class SettingsStore { getCurrentCustomSchema = async (id) => { let customNames = null; - if (window[`${EDITOR_STATE_NAME}`]?.customNames) { - customNames = window[`${EDITOR_STATE_NAME}`].customNames; - window[`${EDITOR_STATE_NAME}`].customNames = null; + if (window?.__ASC_INITIAL_EDITOR_STATE__?.customNames) { + customNames = window.__ASC_INITIAL_EDITOR_STATE__.customNames; + window.__ASC_INITIAL_EDITOR_STATE__.customNames = null; } else customNames = await api.settings.getCurrentCustomSchema(id); this.customNames = customNames; }; @@ -438,8 +438,8 @@ class SettingsStore { getBuildVersionInfo = async () => { let versionInfo = null; - if (window[`${EDITOR_STATE_NAME}`]?.versionInfo) - versionInfo = window[`${EDITOR_STATE_NAME}`].versionInfo; + if (window?.__ASC_INITIAL_EDITOR_STATE__?.versionInfo) + versionInfo = window.__ASC_INITIAL_EDITOR_STATE__.versionInfo; else versionInfo = await api.settings.getBuildVersion(); this.setBuildVersionInfo(versionInfo); }; diff --git a/packages/asc-web-common/store/UserStore.js b/packages/asc-web-common/store/UserStore.js index 90297d786d..12539cc7ca 100644 --- a/packages/asc-web-common/store/UserStore.js +++ b/packages/asc-web-common/store/UserStore.js @@ -1,6 +1,5 @@ import { makeAutoObservable } from "mobx"; import api from "../api"; -import { EDITOR_STATE_NAME } from "../constants"; class UserStore { user = null; @@ -14,8 +13,8 @@ class UserStore { loadCurrentUser = async () => { let user = null; - if (window[`${EDITOR_STATE_NAME}`]?.user) - user = window[`${EDITOR_STATE_NAME}`].user; + if (window?.__ASC_INITIAL_EDITOR_STATE__?.user) + user = window.__ASC_INITIAL_EDITOR_STATE__.user; else user = await api.people.getUser(); this.setUser(user); diff --git a/web/ASC.Web.Editor/src/client/bootstrap.js b/web/ASC.Web.Editor/src/client/bootstrap.js index 2ab478f498..8bb4813193 100644 --- a/web/ASC.Web.Editor/src/client/bootstrap.js +++ b/web/ASC.Web.Editor/src/client/bootstrap.js @@ -4,9 +4,8 @@ import { registerSW } from "@appserver/common/sw/helper"; import App from "./App.js"; import pkg from "../../package.json"; import { initI18n } from "./helpers/utils.js"; -import { EDITOR_STATE_NAME } from "@appserver/common/constants"; -const propsObj = window[`${EDITOR_STATE_NAME}`]; +const propsObj = window.__ASC_INITIAL_EDITOR_STATE__; const initialI18nStoreASC = window.initialI18nStoreASC; const initialLanguage = window.initialLanguage; diff --git a/web/ASC.Web.Editor/src/server/lib/template.js b/web/ASC.Web.Editor/src/server/lib/template.js index 94268b8679..25bb1448a1 100644 --- a/web/ASC.Web.Editor/src/server/lib/template.js +++ b/web/ASC.Web.Editor/src/server/lib/template.js @@ -1,6 +1,5 @@ import { getFavicon, getScripts } from "./helpers"; import pkg from "../../../package.json"; -import { EDITOR_STATE_NAME } from "@appserver/common/constants"; export default function template( initialEditorState = {}, @@ -34,8 +33,10 @@ export default function template( } const scripts = ` -