1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-06 17:33:18 +00:00

Improve current folder updated notification (#2704)

This commit is contained in:
王健辉
2018-12-25 10:25:08 +08:00
committed by Daniel Pan
parent a180723baa
commit fbc9f2a9de
2 changed files with 20 additions and 2 deletions

View File

@@ -39,6 +39,7 @@ class DirView extends React.Component {
errorMsg: '', errorMsg: '',
}; };
window.onpopstate = this.onpopstate; window.onpopstate = this.onpopstate;
this.lastModifyTime = new Date();
} }
onpopstate = (event) => { onpopstate = (event) => {
@@ -97,7 +98,15 @@ class DirView extends React.Component {
collabServer.unwatchRepo(this.props.repoID); collabServer.unwatchRepo(this.props.repoID);
} }
componentDidUpdate() {
this.lastModifyTime = new Date();
}
onRepoUpdateEvent = () => { onRepoUpdateEvent = () => {
let currentTime = new Date();
if ((parseFloat(currentTime - this.lastModifyTime)/1000) <= 5) {
return;
}
let repoID = this.props.repoID; let repoID = this.props.repoID;
let { path, dirID } = this.state; let { path, dirID } = this.state;
seafileAPI.dirMetaData(repoID, path).then((res) => { seafileAPI.dirMetaData(repoID, path).then((res) => {
@@ -107,7 +116,7 @@ class DirView extends React.Component {
{gettext('This folder has been updated. ')} {gettext('This folder has been updated. ')}
<a href='' >{gettext('Refresh')}</a> <a href='' >{gettext('Refresh')}</a>
</span>, </span>,
{duration: 3600} {id: 'repo_updated', duration: 3600}
); );
} }
}) })

View File

@@ -53,6 +53,7 @@ class Wiki extends Component {
}; };
window.onpopstate = this.onpopstate; window.onpopstate = this.onpopstate;
this.hash = ''; this.hash = '';
this.lastModifyTime = new Date();
} }
componentWillMount() { componentWillMount() {
@@ -87,7 +88,15 @@ class Wiki extends Component {
collabServer.unwatchRepo(repoID); collabServer.unwatchRepo(repoID);
} }
componentDidUpdate() {
this.lastModifyTime = new Date();
}
onRepoUpdateEvent = () => { onRepoUpdateEvent = () => {
let currentTime = new Date();
if ((parseFloat(currentTime - this.lastModifyTime)/1000) <= 5) {
return;
}
let { path, dirID } = this.state; let { path, dirID } = this.state;
seafileAPI.dirMetaData(repoID, path).then((res) => { seafileAPI.dirMetaData(repoID, path).then((res) => {
if (res.data.id !== dirID) { if (res.data.id !== dirID) {
@@ -96,7 +105,7 @@ class Wiki extends Component {
{gettext('This folder has been updated. ')} {gettext('This folder has been updated. ')}
<a href='' >{gettext('Refresh')}</a> <a href='' >{gettext('Refresh')}</a>
</span>, </span>,
{duration: 3600} {id: 'repo_updated', duration: 3600}
); );
} }
}) })