From db88c11101c0fdb37fc75c598ba2fe2df0ba2ed0 Mon Sep 17 00:00:00 2001 From: Nicolas Brichet Date: Fri, 6 Sep 2024 17:25:14 +0200 Subject: [PATCH] Use getter and setter for the config in the collaborative chat --- .../src/factory.ts | 29 ++++++++++++++----- .../src/index.ts | 4 +-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/packages/jupyterlab-collaborative-chat/src/factory.ts b/packages/jupyterlab-collaborative-chat/src/factory.ts index 02d0820..312e094 100644 --- a/packages/jupyterlab-collaborative-chat/src/factory.ts +++ b/packages/jupyterlab-collaborative-chat/src/factory.ts @@ -14,7 +14,7 @@ import { ABCWidgetFactory, DocumentRegistry } from '@jupyterlab/docregistry'; import { IRenderMimeRegistry } from '@jupyterlab/rendermime'; import { Contents, User } from '@jupyterlab/services'; import { CommandRegistry } from '@lumino/commands'; -import { Signal } from '@lumino/signaling'; +import { ISignal, Signal } from '@lumino/signaling'; import { CollaborativeChatModel } from './model'; import { CollaborativeChatPanel } from './widget'; @@ -31,14 +31,29 @@ export class WidgetConfig implements IWidgetConfig { * The constructor of the WidgetConfig. */ constructor(config: Partial) { - this.config = config; - this.configChanged.connect((_, config) => { - this.config = { ...this.config, ...config }; - }); + this._config = config; + } + + /** + * Getter and setter for the config. + */ + get config(): Partial { + return this._config; + } + set config(value: Partial) { + this._config = { ...this._config, ...value }; + this._configChanged.emit(value); + } + + /** + * Getter for the configChanged signal + */ + get configChanged(): ISignal> { + return this._configChanged; } - config: Partial; - configChanged = new Signal>(this); + private _config: Partial; + private _configChanged = new Signal>(this); } /** diff --git a/packages/jupyterlab-collaborative-chat/src/index.ts b/packages/jupyterlab-collaborative-chat/src/index.ts index d47a7da..bbefa6e 100644 --- a/packages/jupyterlab-collaborative-chat/src/index.ts +++ b/packages/jupyterlab-collaborative-chat/src/index.ts @@ -137,12 +137,12 @@ const docFactories: JupyterFrontEndPlugin = { unreadNotifications = setting.get('unreadNotifications') .composite as boolean; enableCodeToolbar = setting.get('enableCodeToolbar').composite as boolean; - widgetConfig.configChanged.emit({ + widgetConfig.config = { sendWithShiftEnter, stackMessages, unreadNotifications, enableCodeToolbar - }); + }; } if (settingRegistry) {