Editor: add redirect if app is default
This commit is contained in:
parent
336eeeabb9
commit
c2cf76cfd6
@ -5,7 +5,7 @@ import Button from "@docspace/components/button";
|
||||
import Link from "@docspace/components/link";
|
||||
|
||||
import { getLogoFromPath } from "@docspace/common/utils";
|
||||
import { getDeepLink } from "../../helpers/deepLinkHelper";
|
||||
import { getDeepLink, DL_URL } from "../../helpers/deepLinkHelper";
|
||||
|
||||
import {
|
||||
StyledSimpleNav,
|
||||
@ -15,10 +15,6 @@ import {
|
||||
StyledActionsWrapper,
|
||||
} from "./StyledDeepLink";
|
||||
|
||||
const DL_ANDROID = "com.onlyoffice.documents";
|
||||
const DL_IOS = "944896972";
|
||||
const DL_URL = "oodocuments://openfile";
|
||||
|
||||
const DeepLink = ({ fileInfo, logoUrls, userEmail, setIsShowDeepLink }) => {
|
||||
const [isRemember, setIsRemember] = useState(false);
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import styled from "styled-components";
|
||||
import { isMobile, isIOS, deviceType, isMobileOnly } from "react-device-detect";
|
||||
import combineUrl from "@docspace/common/utils/combineUrl";
|
||||
import { FolderType, EDITOR_ID } from "@docspace/common/constants";
|
||||
@ -23,9 +24,15 @@ import { assign } from "@docspace/common/utils";
|
||||
import toastr from "@docspace/components/toast/toastr";
|
||||
import { DocumentEditor } from "@onlyoffice/document-editor-react";
|
||||
import ErrorContainer from "@docspace/common/components/ErrorContainer";
|
||||
import styled from "styled-components";
|
||||
import DeepLink from "./DeepLink";
|
||||
|
||||
import {
|
||||
getDeepLink,
|
||||
DL_URL,
|
||||
DL_IOS,
|
||||
DL_ANDROID,
|
||||
} from "../helpers/deepLinkHelper";
|
||||
|
||||
toast.configure();
|
||||
|
||||
const onSDKInfo = (event) => {
|
||||
@ -112,6 +119,29 @@ function Editor({
|
||||
if (isMobileOnly && !defaultOpenDocument) {
|
||||
setIsShowDeepLink(true);
|
||||
}
|
||||
|
||||
if (isMobileOnly && defaultOpenDocument === "app") {
|
||||
const nav = navigator.userAgent;
|
||||
const storeUrl =
|
||||
nav.includes("iPhone;") || nav.includes("iPad;")
|
||||
? `https://apps.apple.com/app/id${DL_IOS}`
|
||||
: `https://play.google.com/store/apps/details?id=${DL_ANDROID}`;
|
||||
|
||||
window.location = getDeepLink(
|
||||
window.location.origin,
|
||||
user.email,
|
||||
fileInfo,
|
||||
DL_URL
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
if (document.hasFocus()) {
|
||||
window.location.replace(storeUrl);
|
||||
} else {
|
||||
history.goBack();
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -1,3 +1,7 @@
|
||||
export const DL_ANDROID = "com.onlyoffice.documents";
|
||||
export const DL_IOS = "944896972";
|
||||
export const DL_URL = "oodocuments://openfile";
|
||||
|
||||
export const getDeepLink = (location, email, file, url) => {
|
||||
const jsonData = {
|
||||
portal: location,
|
||||
|
Loading…
Reference in New Issue
Block a user