Web: Files: Remove color flicker loader on instant restoration of history.
This commit is contained in:
parent
cc9857c904
commit
ac0e803072
@ -16,6 +16,7 @@ class SectionBodyContent extends React.Component {
|
||||
};
|
||||
this.listKey = 0;
|
||||
this.listRef = React.createRef();
|
||||
this.timerId = null;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
@ -34,10 +35,26 @@ class SectionBodyContent extends React.Component {
|
||||
fetchFileVersions(fileId).then(() => setIsLoading(false));
|
||||
};
|
||||
|
||||
onSetRestoreProcess = (isRestoreProcess) => {
|
||||
onSetRestoreProcess = (restoring) => {
|
||||
const { isRestoreProcess } = this.state;
|
||||
|
||||
if (restoring) {
|
||||
this.timerId = setTimeout(
|
||||
() =>
|
||||
this.setState({
|
||||
isRestoreProcess,
|
||||
isRestoreProcess: restoring,
|
||||
}),
|
||||
100
|
||||
);
|
||||
} else {
|
||||
clearTimeout(this.timerId);
|
||||
this.timerId = null;
|
||||
|
||||
restoring !== isRestoreProcess &&
|
||||
this.setState({
|
||||
isRestoreProcess: restoring,
|
||||
});
|
||||
}
|
||||
};
|
||||
onUpdateHeight = (i, itemHeight) => {
|
||||
if (this.listRef.current) {
|
||||
@ -85,6 +102,7 @@ class SectionBodyContent extends React.Component {
|
||||
const { versions, isLoading } = this.props;
|
||||
|
||||
const renderList = ({ height, width }) => {
|
||||
console.log("this.state", this.state);
|
||||
return (
|
||||
<StyledVersionList isRestoreProcess={this.state.isRestoreProcess}>
|
||||
<List
|
||||
|
@ -7,6 +7,7 @@ class VersionHistoryStore {
|
||||
versions = null;
|
||||
filesStore = null;
|
||||
showProgressBar = false;
|
||||
timerId = null;
|
||||
|
||||
constructor(filesStore) {
|
||||
makeObservable(this, {
|
||||
@ -79,7 +80,7 @@ class VersionHistoryStore {
|
||||
};
|
||||
|
||||
restoreVersion = (id, version) => {
|
||||
this.setShowProgressBar(true);
|
||||
this.timerId = setTimeout(() => this.setShowProgressBar(true), 100);
|
||||
|
||||
return api.files
|
||||
.versionRestore(id, version)
|
||||
@ -87,9 +88,13 @@ class VersionHistoryStore {
|
||||
const updatedVersions = this.versions.slice();
|
||||
updatedVersions.splice(1, 0, newVersion);
|
||||
this.setVerHistoryFileVersions(updatedVersions);
|
||||
this.setShowProgressBar(false);
|
||||
})
|
||||
.catch(() => this.setShowProgressBar(false));
|
||||
.catch((e) => console.error(e))
|
||||
.finally(() => {
|
||||
clearTimeout(this.timerId);
|
||||
this.timerId = null;
|
||||
this.setShowProgressBar(false);
|
||||
});
|
||||
};
|
||||
|
||||
updateCommentVersion = (id, comment, version) => {
|
||||
|
Loading…
Reference in New Issue
Block a user