Web: Files: refactoring private rooms page

This commit is contained in:
Nikita Gopienko 2021-06-28 14:36:38 +03:00
parent 1b685a7b5e
commit 2cd83d0897
3 changed files with 12 additions and 14 deletions

View File

@ -160,7 +160,7 @@ export default function withFileActions(WrappedFileItem) {
encrypted,
} = item;
if (encrypted && isPrivacy) return checkProtocol(item.id);
if (encrypted && isPrivacy) return checkProtocol(item.id, true);
if (isTrashFolder) return;

View File

@ -144,18 +144,19 @@ export const loopTreeFolders = (
});
};
export const checkProtocol = (fileId) =>
export const checkProtocol = (fileId, withRedirect) =>
new Promise((resolve, reject) => {
const onBlur = () => {
clearTimeout(timeout);
window.removeEventListener("blur", onBlur);
resolve(true);
resolve();
};
const timeout = setTimeout(() => {
reject(false);
reject();
window.removeEventListener("blur", onBlur);
window.open(`/products/files/private?fileId=${fileId}`, "_blank");
withRedirect &&
window.open(`/products/files/private?fileId=${fileId}`, "_blank");
}, 1000);
window.addEventListener("blur", onBlur);

View File

@ -102,15 +102,12 @@ const PrivacyPageComponent = ({ t, history, tReady }) => {
const onOpenEditorsPopup = async () => {
setIsDisabled(true);
const isInstalled = await checkProtocol(
history.location.search.split("=")[1]
);
if (isInstalled) setIsDisabled(false);
else {
setIsDisabled(false);
toastr.info(t("PrivacyEditors"));
}
checkProtocol(history.location.search.split("=")[1])
.then(() => setIsDisabled(false))
.catch(() => {
setIsDisabled(false);
toastr.info(t("PrivacyEditors"));
});
};
return !tReady ? (