Web: Editor: Fixed converting file when open in new tab.
This commit is contained in:
parent
92f0126e5d
commit
e634b5c72f
@ -536,10 +536,13 @@ export function getNewFiles(folderId) {
|
||||
});
|
||||
}
|
||||
|
||||
export function convertFile(fileId) {
|
||||
export function convertFile(fileId, sync = false) {
|
||||
const data = { sync };
|
||||
|
||||
return request({
|
||||
method: "put",
|
||||
url: `/files/file/${fileId}/checkconversion`,
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2,12 +2,12 @@ import authStore from "@appserver/common/store/AuthStore";
|
||||
import { AppServerConfig } from "@appserver/common/constants";
|
||||
import config from "../../package.json";
|
||||
import { combineUrl, toUrlParams } from "@appserver/common/utils";
|
||||
import {
|
||||
addFileToRecentlyViewed,
|
||||
} from "@appserver/common/api/files";
|
||||
import { addFileToRecentlyViewed } from "@appserver/common/api/files";
|
||||
import i18n from "./i18n";
|
||||
|
||||
import { request } from "@appserver/common/api/client";
|
||||
import docserviceStore from "../store/DocserviceStore";
|
||||
|
||||
export const setDocumentTitle = (subTitle = null) => {
|
||||
const { isAuthenticated, settingsStore, product: currentModule } = authStore;
|
||||
const { organizationName } = settingsStore;
|
||||
@ -98,3 +98,9 @@ export const SaveAs = (title, url, folderId, openNewTab) => {
|
||||
"_blank"
|
||||
);
|
||||
};
|
||||
|
||||
export const canConvert = (fileExst) => {
|
||||
const { canConvert } = docserviceStore;
|
||||
|
||||
return canConvert(fileExst);
|
||||
};
|
||||
|
@ -26,6 +26,7 @@ import {
|
||||
removeFromFavorite,
|
||||
markAsFavorite,
|
||||
getPresignedUri,
|
||||
convertFile,
|
||||
} from "@appserver/common/api/files";
|
||||
import { checkIsAuthenticated } from "@appserver/common/api/user";
|
||||
import { getUser } from "@appserver/common/api/people";
|
||||
@ -37,7 +38,7 @@ import { homepage } from "../package.json";
|
||||
|
||||
import { AppServerConfig } from "@appserver/common/constants";
|
||||
import SharingDialog from "files/SharingDialog";
|
||||
import { getDefaultFileName, SaveAs } from "files/utils";
|
||||
import { getDefaultFileName, SaveAs, canConvert } from "files/utils";
|
||||
import SelectFileDialog from "files/SelectFileDialog";
|
||||
import SelectFolderDialog from "files/SelectFolderDialog";
|
||||
import { StyledSelectFolder, StyledSelectFile } from "./StyledEditor";
|
||||
@ -150,6 +151,15 @@ const Editor = () => {
|
||||
if (successAuth) {
|
||||
try {
|
||||
fileInfo = await getFileInfo(fileId);
|
||||
|
||||
if (url.indexOf("#message/")) {
|
||||
const needConvert = canConvert(fileInfo.fileExst);
|
||||
|
||||
if (needConvert) {
|
||||
const convert = await convertFile(fileId, true);
|
||||
location.href = convert[0].result.webUrl;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user