Skip to content

Commit 0754bc7

Browse files
Remove unused chat feature (#346)
* Remove unused chat feature * Review
1 parent 1492678 commit 0754bc7

File tree

3 files changed

+1
-80
lines changed

3 files changed

+1
-80
lines changed

packages/docprovider/src/awareness.ts

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,16 @@
66
import { User } from '@jupyterlab/services';
77

88
import { IDisposable } from '@lumino/disposable';
9-
import { IStream, Stream } from '@lumino/signaling';
109

1110
import { IAwareness } from '@jupyter/ydoc';
1211

13-
import * as decoding from 'lib0/decoding';
14-
import * as encoding from 'lib0/encoding';
1512
import { WebsocketProvider } from 'y-websocket';
1613

17-
import { MessageType } from './utils';
18-
import { IAwarenessProvider } from './tokens';
19-
2014
export interface IContent {
2115
type: string;
2216
body: string;
2317
}
2418

25-
export interface IChatMessage {
26-
sender: string;
27-
timestamp: number;
28-
content: IContent;
29-
}
30-
3119
/**
3220
* A class to provide Yjs synchronization over WebSocket.
3321
*
@@ -36,7 +24,7 @@ export interface IChatMessage {
3624
*/
3725
export class WebSocketAwarenessProvider
3826
extends WebsocketProvider
39-
implements IAwarenessProvider, IDisposable
27+
implements IDisposable
4028
{
4129
/**
4230
* Construct a new WebSocketAwarenessProvider
@@ -55,33 +43,12 @@ export class WebSocketAwarenessProvider
5543
.then(() => this._onUserChanged(this._user))
5644
.catch(e => console.error(e));
5745
this._user.userChanged.connect(this._onUserChanged, this);
58-
59-
this._messageStream = new Stream(this);
60-
61-
this.messageHandlers[MessageType.CHAT] = (
62-
encoder,
63-
decoder,
64-
provider,
65-
emitSynced,
66-
messageType
67-
) => {
68-
const content = decoding.readVarString(decoder);
69-
const data = JSON.parse(content) as IChatMessage;
70-
this._messageStream.emit(data);
71-
};
7246
}
7347

7448
get isDisposed(): boolean {
7549
return this._isDisposed;
7650
}
7751

78-
/**
79-
* A signal to subscribe for incoming messages.
80-
*/
81-
get messageStream(): IStream<this, IChatMessage> {
82-
return this._messageStream;
83-
}
84-
8552
dispose(): void {
8653
if (this._isDisposed) {
8754
return;
@@ -92,31 +59,13 @@ export class WebSocketAwarenessProvider
9259
this.destroy();
9360
}
9461

95-
/**
96-
* Send a message to every collaborator.
97-
*
98-
* @param msg message
99-
*/
100-
sendMessage(msg: string): void {
101-
const data: IContent = {
102-
type: 'text',
103-
body: msg
104-
};
105-
const encoder = encoding.createEncoder();
106-
encoding.writeVarUint(encoder, MessageType.CHAT);
107-
encoding.writeVarString(encoder, JSON.stringify(data));
108-
this.ws!.send(encoding.toUint8Array(encoder));
109-
}
110-
11162
private _onUserChanged(user: User.IManager): void {
11263
this._awareness.setLocalStateField('user', user.identity);
11364
}
11465

11566
private _isDisposed = false;
11667
private _user: User.IManager;
11768
private _awareness: IAwareness;
118-
119-
private _messageStream: Stream<this, IChatMessage>;
12069
}
12170

12271
/**

packages/docprovider/src/tokens.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import { DocumentChange, IAwareness, YDocument } from '@jupyter/ydoc';
55
import { Contents } from '@jupyterlab/services';
66

77
import { Token } from '@lumino/coreutils';
8-
import { IStream } from '@lumino/signaling';
9-
10-
import { IChatMessage } from './awareness';
118

129
/**
1310
* The collaborative drive.
@@ -56,20 +53,3 @@ export interface ISharedModelFactory extends Contents.ISharedFactory {
5653
factory: SharedDocumentFactory
5754
): void;
5855
}
59-
60-
/**
61-
* A provider interface for global awareness features.
62-
*/
63-
export interface IAwarenessProvider {
64-
/**
65-
* A signal to subscribe for incoming messages.
66-
*/
67-
readonly messageStream: IStream<this, IChatMessage>;
68-
69-
/**
70-
* Send a message to every collaborator.
71-
*
72-
* @param msg message
73-
*/
74-
sendMessage(msg: string): void;
75-
}

packages/docprovider/src/utils.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)