Merge branch 'hotfix/v0.0.4' of github.com:ONLYOFFICE/AppServer into hotfix/v0.0.4

This commit is contained in:
Vladislav Makhov 2020-12-21 14:18:44 +03:00
commit af6e67016d
8 changed files with 100 additions and 7 deletions

View File

@ -12,7 +12,7 @@
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<link id="favicon" rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!-- Tell the browser it's a PWA -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@ -2,9 +2,25 @@ 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 { isIOS, deviceType } from "react-device-detect";
import { setDocumentTitle } from "../../../helpers/utils";
import { changeTitle, setFavicon, isIPad } from "./utils";
import throttle from "lodash/throttle";
const { getObjectByLocation, showLoader, hideLoader, tryRedirectTo } = utils;
let documentIsReady = false;
let docTitle = null;
let fileType = null;
let docSaved = null;
const throttledChangeTitle = throttle(
() => changeTitle(docSaved, docTitle),
500
);
class PureEditor extends React.Component {
constructor(props) {
super(props);
@ -28,8 +44,10 @@ class PureEditor extends React.Component {
console.log("PureEditor componentDidMount", fileId, doc);
const vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty("--vh", `${vh}px`);
if (isIPad()) {
const vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty("--vh", `${vh}px`);
}
showLoader();
@ -73,23 +91,62 @@ class PureEditor extends React.Component {
onLoad = (config) => {
try {
docTitle = config.document.title;
fileType = config.document.fileType;
setFavicon(fileType);
setDocumentTitle(docTitle);
if (window.innerWidth < 720) {
config.type = "mobile";
}
const events = {
events: {
onDocumentStateChange: this.onDocumentStateChange,
onMetaChange: this.onMetaChange,
onDocumentReady: this.onDocumentReady,
},
};
const newConfig = Object.assign(config, events);
if (!window.DocsAPI) throw new Error("DocsAPI is not defined");
hideLoader();
window.DocsAPI.DocEditor("editor", config);
window.DocsAPI.DocEditor("editor", newConfig);
} catch (error) {
console.log(error);
toastr.error(error.message, null, 0, true);
}
};
onDocumentStateChange = (event) => {
if (!documentIsReady) return;
docSaved = !event.data;
throttledChangeTitle();
};
onDocumentReady = () => {
documentIsReady = true;
};
onMetaChange = (event) => {
const newTitle = event.data.title;
if (newTitle && newTitle !== docTitle) {
setDocumentTitle(newTitle);
docTitle = newTitle;
}
};
render() {
return (
<Box widthProp="100vw" heightProp="100vh">
<Box
widthProp="100vw"
heightProp={isIPad() ? "calc(var(--vh, 1vh) * 100)" : "100vh"}
>
<Toast />
{!this.state.isLoading ? (

View File

@ -0,0 +1,34 @@
import { setDocumentTitle } from "../../../helpers/utils";
import { isIOS, deviceType } from "react-device-detect";
import textIcon from "./icons/text.ico";
import presentationIcon from "./icons/presentation.ico";
import spreadsheetIcon from "./icons/spreadsheet.ico";
export const changeTitle = (docSaved, docTitle) => {
docSaved ? setDocumentTitle(docTitle) : setDocumentTitle(`*${docTitle}`);
};
export const setFavicon = (fileType) => {
const favicon = document.getElementById("favicon");
if (!favicon) return;
switch (fileType) {
case "docx":
favicon.href = textIcon;
break;
case "pptx":
favicon.href = presentationIcon;
break;
case "xlsx":
favicon.href = spreadsheetIcon;
break;
default:
break;
}
};
export const isIPad = () => {
return isIOS && deviceType === "tablet";
};

View File

@ -1164,8 +1164,10 @@ namespace ASC.Files.Core.Data
public Dictionary<string, string> GetBunchObjectIDs(List<int> folderIDs)
{
var folderSIds = folderIDs.Select(r => r.ToString()).ToList();
return Query(FilesDbContext.BunchObjects)
.Where(r => folderIDs.Any(a => a.ToString() == r.LeftNode))
.Where(r => folderSIds.Any(a => a == r.LeftNode))
.ToDictionary(r => r.LeftNode, r => r.RightNode);
}

View File

@ -588,7 +588,7 @@ namespace ASC.Files.Core.Security
foreach (var e in filteredEntries)
{
var adapter = findedAdapters[e.RootFolderId.ToString()];
findedAdapters.TryGetValue(e.RootFolderId.ToString(), out var adapter);
if (adapter == null) continue;