Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock notification #7026

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Lock notification #7026

wants to merge 11 commits into from

Conversation

awu0403
Copy link
Contributor

@awu0403 awu0403 commented Nov 11, 2024

No description provided.

class WebSocketService {
constructor(onMessageCallback, repoId) {

this.url = 'ws://localhost:8083'; // WebSocket address;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url不要在这里写死, 写到seahub_settings里面然后,通过html中继器来读取

@@ -146,8 +146,40 @@ class LibContentView extends React.Component {
componentDidMount() {
this.unsubscribeEvent = this.props.eventBus.subscribe(EVENT_BUS_TYPE.SEARCH_LIBRARY_CONTENT, this.onSearchedClick);
this.calculatePara(this.props);
this.socket = new WebSocketService(this.onMessageCallback, this.props.repoID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个写在constructor的构造方法下面

@@ -0,0 +1,101 @@
import { userAPI } from '../utils/user-api';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文件名改成 listen-notification --> websocket-service.js


handleMessage(data) {
switch (data.type) {
case 'file-lock-changed':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不需要用case的吧, 在回调处进行判断就可以了。 websocke-service层面这里不需要知道具体的数据类型(尽量与seafile中的业务数据分离)。 接受到消息,把数据传递给回调函数, 然后在调用函数的外部组件中去扩展就可以了

}

close() {
this.shouldReconnect = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里需要发送请求来unsubscribe这个repo

this.url = 'ws://localhost:8083'; // WebSocket address;
this.repoId = repoId;
this.socket = null;
this.heartbeatInterval = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里heartbetInterval好像没用到, 看看是不是可以删掉

@awu0403 awu0403 force-pushed the lock-notification branch 2 times, most recently from 63acdd5 to a276945 Compare November 25, 2024 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants