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:
@@ -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}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@@ -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}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user