Fix Bug 60344

This commit is contained in:
Elyor Djalilov 2022-12-27 15:23:05 +05:00
parent 0d4000df46
commit 74f30f2d38
3 changed files with 47 additions and 54 deletions

View File

@ -1,5 +1,4 @@
import React from "react";
import { inject, observer } from "mobx-react";
import Link from "@docspace/components/link";
import Checkbox from "@docspace/components/checkbox";
import TableCell from "@docspace/components/table-container/TableCell";
@ -15,7 +14,6 @@ const FileNameCell = ({
theme,
t,
inProgress,
isLoading,
}) => {
const { title } = item;
@ -25,7 +23,7 @@ const FileNameCell = ({
return (
<>
{inProgress || isLoading ? (
{inProgress ? (
<Loader
className="table-container_row-loader"
type="oval"
@ -65,8 +63,4 @@ const FileNameCell = ({
);
};
export default inject(({ filesActionsStore }) => {
return {
isLoading: filesActionsStore.isLoading,
};
})(observer(FileNameCell));
export default FileNameCell;

View File

@ -175,19 +175,10 @@ class ContextOptionsStore {
setIsVerHistoryPanel(true);
};
finalizeVersion = async (id) => {
let timer = null;
try {
timer = setTimeout(() => {
this.filesActionsStore.setIsLoading(true);
}, 200);
await this.filesActionsStore.finalizeVersionAction(id);
} catch (err) {
toastr.error(err);
} finally {
this.filesActionsStore.setIsLoading(false);
clearTimeout(timer);
}
finalizeVersion = (id) => {
this.filesActionsStore
.finalizeVersionAction(id)
.catch((err) => toastr.error(err));
};
onClickFavorite = (e, id, t) => {
@ -204,30 +195,21 @@ class ContextOptionsStore {
.catch((err) => toastr.error(err));
};
lockFile = async (item, t) => {
let timer = null;
lockFile = (item, t) => {
const { id, locked } = item;
const {
setSelection: setInfoPanelSelection,
} = this.authStore.infoPanelStore;
try {
timer = setTimeout(() => {
this.filesActionsStore.setIsLoading(true);
}, 200);
await this.filesActionsStore
.lockFileAction(id, !locked)
.then(() =>
locked
? toastr.success(t("Translations:FileUnlocked"))
: toastr.success(t("Translations:FileLocked"))
)
.then(() => setInfoPanelSelection({ ...item, locked: !locked }));
} catch (err) {
toastr.error(err);
} finally {
this.filesActionsStore.setIsLoading(false), clearTimeout(timer);
}
this.filesActionsStore
.lockFileAction(id, !locked)
.then(() =>
locked
? toastr.success(t("Translations:FileUnlocked"))
: toastr.success(t("Translations:FileLocked"))
)
.then(() => setInfoPanelSelection({ ...item, locked: !locked }))
.catch((err) => toastr.error(err));
};
onClickLinkForPortal = (item, t) => {

View File

@ -45,7 +45,6 @@ class FilesActionStore {
itemOpenLocation = null;
isLoadedLocationFiles = false;
isLoadedSearchFiles = false;
isLoading = false;
constructor(
authStore,
@ -758,19 +757,41 @@ class FilesActionStore {
.then(() => fetchFiles(this.selectedFolderStore.id, filter, true, true));
};
lockFileAction = (id, locked) => {
lockFileAction = async (id, locked) => {
let timer = null;
const { setFile } = this.filesStore;
return lockFile(id, locked).then((res) => setFile(res));
try {
timer = setTimeout(() => {
this.filesStore.setActiveFiles([id]);
}, 200);
await lockFile(id, locked).then((res) => {
setFile(res), this.filesStore.setActiveFiles([]);
});
} catch (err) {
toastr.error(err);
} finally {
clearTimeout(timer);
}
};
finalizeVersionAction = (id) => {
finalizeVersionAction = async (id) => {
let timer = null;
const { setFile } = this.filesStore;
return finalizeVersion(id, 0, false).then((res) => {
if (res && res[0]) {
setFile(res[0]);
}
});
try {
timer = setTimeout(() => {
this.filesStore.setActiveFiles([id]);
}, 200);
await finalizeVersion(id, 0, false).then((res) => {
if (res && res[0]) {
setFile(res[0]);
this.filesStore.setActiveFiles([]);
}
});
} catch (err) {
toastr.error(err);
} finally {
clearTimeout(timer);
}
};
duplicateAction = (item, label) => {
@ -1102,10 +1123,6 @@ class FilesActionStore {
this.isLoadedSearchFiles = isLoadedSearchFiles;
};
setIsLoading = (isLoading) => {
this.isLoading = isLoading;
};
openLocationAction = async (locationId) => {
this.setIsLoadedLocationFiles(false);
this.filesStore.setBufferSelection(null);