1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-23 12:27:48 +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

@@ -1,14 +1,11 @@
import React from 'react';
import io from 'socket.io-client';
import toaster from '../components/toast';
import { seafileAPI } from './seafile-api';
import { gettext, name, username, contactEmail, seafileCollabServer } from './constants';
import { name, username, contactEmail, seafileCollabServer } from './constants';
const socket = io(seafileCollabServer);
class CollabServer {
watchRepo(repoID, path, dirID) {
watchRepo(repoID, fn) {
socket.emit('repo_update', {
request: 'watch_update',
repo_id: repoID,
@@ -19,23 +16,19 @@ class CollabServer {
},
});
socket.on('repo_update', () => {
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}
);
}
})
})
socket.on('repo_update', fn)
}
unwatchRepo() {
socket.off()
unwatchRepo(repoID) {
socket.emit('repo_update', {
request: 'unwatch_update',
repo_id: repoID,
user: {
name: name,
username: username,
contact_email: contactEmail,
},
});
}
}