Added reqDesktop on DocEditor page

This commit is contained in:
Alexey Safronov 2020-12-29 18:43:12 +03:00
parent 7b4dc42620
commit d54a5a0656

View File

@ -1,7 +1,8 @@
import React from "react";
import { withRouter } from "react-router";
import { Toast, Box } from "asc-web-components";
import { utils, api, toastr, Loaders } from "asc-web-common";
import { utils, api, toastr, Loaders, regDesktop } from "asc-web-common";
import { isIOS, deviceType } from "react-device-detect";
import { setDocumentTitle } from "../../../helpers/utils";
import { changeTitle, setFavicon, isIPad } from "./utils";
@ -28,17 +29,19 @@ class PureEditor extends React.Component {
const urlParams = getObjectByLocation(window.location);
const fileId = urlParams ? urlParams.fileId || null : null;
const doc = urlParams ? urlParams.doc || null : null;
const desktop = window["AscDesktopEditor"] !== undefined;
this.state = {
fileId,
doc,
isLoading: true,
isDesktop: desktop,
};
}
async componentDidMount() {
try {
const { fileId, doc } = this.state;
const { fileId, doc, isDesktop } = this.state;
if (!fileId) return;
@ -61,6 +64,21 @@ class PureEditor extends React.Component {
const config = await api.files.openEdit(fileId, doc);
if (isDesktop) {
const isEncryption =
config.editorConfig["encryptionKeys"] !== undefined;
const user = await api.people.getUser();
regDesktop(
user,
isEncryption,
config.editorConfig.encryptionKeys,
(keys) => api.files.setEncryptionKeys(keys),
true
);
}
this.setState({ isLoading: false }, () =>
this.loadDocApi(docApiUrl, () => this.onLoad(config))
);
@ -91,6 +109,9 @@ class PureEditor extends React.Component {
onLoad = (config) => {
try {
console.log(config);
docTitle = config.document.title;
fileType = config.document.fileType;
@ -111,6 +132,13 @@ class PureEditor extends React.Component {
const newConfig = Object.assign(config, events);
const { isDesktop } = this.state;
if (isDesktop && newConfig.editorConfig["encryptionKeys"] !== undefined) {
newConfig.editorConfig.encryptionKeys.cryptoEngineId =
"{FFF0E1EB-13DB-4678-B67D-FF0A41DBBCEF}";
}
if (!window.DocsAPI) throw new Error("DocsAPI is not defined");
hideLoader();