Skip to content

Commit

Permalink
Use getter and setter for the config in the collaborative chat
Browse files Browse the repository at this point in the history
  • Loading branch information
brichet committed Sep 6, 2024
1 parent f1e6838 commit db88c11
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
29 changes: 22 additions & 7 deletions packages/jupyterlab-collaborative-chat/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -31,14 +31,29 @@ export class WidgetConfig implements IWidgetConfig {
* The constructor of the WidgetConfig.
*/
constructor(config: Partial<IConfig>) {
this.config = config;
this.configChanged.connect((_, config) => {
this.config = { ...this.config, ...config };
});
this._config = config;
}

/**
* Getter and setter for the config.
*/
get config(): Partial<IConfig> {
return this._config;
}
set config(value: Partial<IConfig>) {
this._config = { ...this._config, ...value };
this._configChanged.emit(value);
}

/**
* Getter for the configChanged signal
*/
get configChanged(): ISignal<WidgetConfig, Partial<IConfig>> {
return this._configChanged;
}

config: Partial<IConfig>;
configChanged = new Signal<this, Partial<IConfig>>(this);
private _config: Partial<IConfig>;
private _configChanged = new Signal<WidgetConfig, Partial<IConfig>>(this);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/jupyterlab-collaborative-chat/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ const docFactories: JupyterFrontEndPlugin<IChatFactory> = {
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) {
Expand Down

0 comments on commit db88c11

Please sign in to comment.