1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-23 04:18:21 +00:00

modify collab server

This commit is contained in:
wangjianhui
2018-12-20 17:48:27 +08:00
parent 5d0386bbad
commit 0349918272
4 changed files with 54 additions and 26 deletions

View File

@@ -51,6 +51,7 @@ class DirView extends React.Component {
// eg: http://127.0.0.1:8000/library/repo_id/repo_name/**/**/\
let location = decodeURIComponent(window.location.href);
let repoID = this.props.repoID;
collabServer.watchRepo(repoID, this.onRepoUpdateEvent);
seafileAPI.getRepoInfo(repoID).then(res => {
let repoInfo = new RepoInfo(res.data);
this.setState({
@@ -70,7 +71,27 @@ class DirView extends React.Component {
}
});
}
componentWillUnmount() {
collabServer.unwatchRepo(this.props.repoID);
}
onRepoUpdateEvent = () => {
let repoID = this.props.repoID;
let { path, dirID } = this.state;
seafileAPI.dirMetaData(repoID, path).then((res) => {
if (res.data.id !== dirID) {
toaster.notify(
<span>
{gettext('This folder has been updated. ')}
<a href='' >{gettext('Refresh')}</a>
</span>,
{duration: 3600}
);
}
})
}
updateDirentList = (filePath) => {
let repoID = this.state.repoID;
this.setState({isDirentListLoading: true});
@@ -83,7 +104,6 @@ class DirView extends React.Component {
direntList: direntList,
dirID: res.headers.oid,
});
collabServer.watchRepo(this.state.repoID, this.state.path, this.state.dirID);
}).catch(() => {
this.setState({pathExist: false});
});