1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-08 02:10:24 +00:00

Fixed the bug that the lock button is displayed only when the page is refreshed (#7102)

This commit is contained in:
杨顺强
2024-11-25 18:13:08 +08:00
committed by GitHub
parent c16e560ff7
commit 4093c27ed7

View File

@@ -117,20 +117,29 @@ class DirentListItem extends React.Component {
}
UNSAFE_componentWillReceiveProps(nextProps) {
if (nextProps.dirent && this.state.dirent && nextProps.dirent.name !== this.state.dirent.name) {
this.setState({
dirent: nextProps.dirent,
}, () => {
if (this.checkGenerateThumbnail(nextProps.dirent)) {
const { repoID, path } = nextProps;
this.isGeneratingThumbnail = true;
this.thumbnailCenter.createThumbnail({
repoID,
path: [path, nextProps.dirent.name].join('/'),
callback: this.updateDirentThumbnail,
});
}
});
if (nextProps.dirent && this.state.dirent) {
if (nextProps.dirent.name !== this.state.dirent.name) {
this.setState({
dirent: nextProps.dirent,
}, () => {
if (this.checkGenerateThumbnail(nextProps.dirent)) {
const { repoID, path } = nextProps;
this.isGeneratingThumbnail = true;
this.thumbnailCenter.createThumbnail({
repoID,
path: [path, nextProps.dirent.name].join('/'),
callback: this.updateDirentThumbnail,
});
}
});
}
if (
nextProps.dirent.is_locked !== this.state.dirent.is_locked ||
nextProps.dirent.starred !== this.state.dirent.starred
) {
this.setState({ dirent: nextProps.dirent });
}
}
}