From 0754bc7022096e70d6a15df1eae106607ff47971 Mon Sep 17 00:00:00 2001 From: David Brochart Date: Mon, 9 Sep 2024 14:39:30 +0200 Subject: [PATCH] Remove unused chat feature (#346) * Remove unused chat feature * Review --- packages/docprovider/src/awareness.ts | 53 +-------------------------- packages/docprovider/src/tokens.ts | 20 ---------- packages/docprovider/src/utils.ts | 8 ---- 3 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 packages/docprovider/src/utils.ts diff --git a/packages/docprovider/src/awareness.ts b/packages/docprovider/src/awareness.ts index 762a9f60..aab9a16c 100644 --- a/packages/docprovider/src/awareness.ts +++ b/packages/docprovider/src/awareness.ts @@ -6,28 +6,16 @@ import { User } from '@jupyterlab/services'; import { IDisposable } from '@lumino/disposable'; -import { IStream, Stream } from '@lumino/signaling'; import { IAwareness } from '@jupyter/ydoc'; -import * as decoding from 'lib0/decoding'; -import * as encoding from 'lib0/encoding'; import { WebsocketProvider } from 'y-websocket'; -import { MessageType } from './utils'; -import { IAwarenessProvider } from './tokens'; - export interface IContent { type: string; body: string; } -export interface IChatMessage { - sender: string; - timestamp: number; - content: IContent; -} - /** * A class to provide Yjs synchronization over WebSocket. * @@ -36,7 +24,7 @@ export interface IChatMessage { */ export class WebSocketAwarenessProvider extends WebsocketProvider - implements IAwarenessProvider, IDisposable + implements IDisposable { /** * Construct a new WebSocketAwarenessProvider @@ -55,33 +43,12 @@ export class WebSocketAwarenessProvider .then(() => this._onUserChanged(this._user)) .catch(e => console.error(e)); this._user.userChanged.connect(this._onUserChanged, this); - - this._messageStream = new Stream(this); - - this.messageHandlers[MessageType.CHAT] = ( - encoder, - decoder, - provider, - emitSynced, - messageType - ) => { - const content = decoding.readVarString(decoder); - const data = JSON.parse(content) as IChatMessage; - this._messageStream.emit(data); - }; } get isDisposed(): boolean { return this._isDisposed; } - /** - * A signal to subscribe for incoming messages. - */ - get messageStream(): IStream { - return this._messageStream; - } - dispose(): void { if (this._isDisposed) { return; @@ -92,22 +59,6 @@ export class WebSocketAwarenessProvider this.destroy(); } - /** - * Send a message to every collaborator. - * - * @param msg message - */ - sendMessage(msg: string): void { - const data: IContent = { - type: 'text', - body: msg - }; - const encoder = encoding.createEncoder(); - encoding.writeVarUint(encoder, MessageType.CHAT); - encoding.writeVarString(encoder, JSON.stringify(data)); - this.ws!.send(encoding.toUint8Array(encoder)); - } - private _onUserChanged(user: User.IManager): void { this._awareness.setLocalStateField('user', user.identity); } @@ -115,8 +66,6 @@ export class WebSocketAwarenessProvider private _isDisposed = false; private _user: User.IManager; private _awareness: IAwareness; - - private _messageStream: Stream; } /** diff --git a/packages/docprovider/src/tokens.ts b/packages/docprovider/src/tokens.ts index 8ac32f4a..bf62b890 100644 --- a/packages/docprovider/src/tokens.ts +++ b/packages/docprovider/src/tokens.ts @@ -5,9 +5,6 @@ import { DocumentChange, IAwareness, YDocument } from '@jupyter/ydoc'; import { Contents } from '@jupyterlab/services'; import { Token } from '@lumino/coreutils'; -import { IStream } from '@lumino/signaling'; - -import { IChatMessage } from './awareness'; /** * The collaborative drive. @@ -56,20 +53,3 @@ export interface ISharedModelFactory extends Contents.ISharedFactory { factory: SharedDocumentFactory ): void; } - -/** - * A provider interface for global awareness features. - */ -export interface IAwarenessProvider { - /** - * A signal to subscribe for incoming messages. - */ - readonly messageStream: IStream; - - /** - * Send a message to every collaborator. - * - * @param msg message - */ - sendMessage(msg: string): void; -} diff --git a/packages/docprovider/src/utils.ts b/packages/docprovider/src/utils.ts deleted file mode 100644 index ff937a76..00000000 --- a/packages/docprovider/src/utils.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* ----------------------------------------------------------------------------- -| Copyright (c) Jupyter Development Team. -| Distributed under the terms of the Modified BSD License. -|----------------------------------------------------------------------------*/ - -export enum MessageType { - CHAT = 125 -}