1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-09 10:50:24 +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

@@ -63,6 +63,7 @@ class Wiki extends Component {
}
componentDidMount() {
collabServer.watchRepo(repoID, this.onRepoUpdateEvent);
seafileAPI.getRepoInfo(repoID).then(res => {
this.setState({
libNeedDecrypt: res.data.lib_need_decrypt,
@@ -82,6 +83,24 @@ class Wiki extends Component {
});
}
componentWillUnmount() {
collabServer.unwatchRepo(repoID);
}
onRepoUpdateEvent = () => {
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}
);
}
})
}
deleteItemAjaxCallback(path, isDir) {
let node = this.state.treeData.getNodeByPath(path);
@@ -282,7 +301,6 @@ class Wiki extends Component {
isDirentListLoading: false,
dirID: res.headers.oid,
});
collabServer.watchRepo(repoID, this.state.path, this.state.dirID);
});
}