Skip to content

Commit 4839eda

Browse files
authored
Use getter and setter for the config in the collaborative chat (#77)
1 parent f1e6838 commit 4839eda

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

packages/jupyterlab-collaborative-chat/src/factory.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { ABCWidgetFactory, DocumentRegistry } from '@jupyterlab/docregistry';
1414
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
1515
import { Contents, User } from '@jupyterlab/services';
1616
import { CommandRegistry } from '@lumino/commands';
17-
import { Signal } from '@lumino/signaling';
17+
import { ISignal, Signal } from '@lumino/signaling';
1818

1919
import { CollaborativeChatModel } from './model';
2020
import { CollaborativeChatPanel } from './widget';
@@ -31,14 +31,29 @@ export class WidgetConfig implements IWidgetConfig {
3131
* The constructor of the WidgetConfig.
3232
*/
3333
constructor(config: Partial<IConfig>) {
34-
this.config = config;
35-
this.configChanged.connect((_, config) => {
36-
this.config = { ...this.config, ...config };
37-
});
34+
this._config = config;
35+
}
36+
37+
/**
38+
* Getter and setter for the config.
39+
*/
40+
get config(): Partial<IConfig> {
41+
return this._config;
42+
}
43+
set config(value: Partial<IConfig>) {
44+
this._config = { ...this._config, ...value };
45+
this._configChanged.emit(value);
46+
}
47+
48+
/**
49+
* Getter for the configChanged signal
50+
*/
51+
get configChanged(): ISignal<WidgetConfig, Partial<IConfig>> {
52+
return this._configChanged;
3853
}
3954

40-
config: Partial<IConfig>;
41-
configChanged = new Signal<this, Partial<IConfig>>(this);
55+
private _config: Partial<IConfig>;
56+
private _configChanged = new Signal<WidgetConfig, Partial<IConfig>>(this);
4257
}
4358

4459
/**

packages/jupyterlab-collaborative-chat/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ const docFactories: JupyterFrontEndPlugin<IChatFactory> = {
137137
unreadNotifications = setting.get('unreadNotifications')
138138
.composite as boolean;
139139
enableCodeToolbar = setting.get('enableCodeToolbar').composite as boolean;
140-
widgetConfig.configChanged.emit({
140+
widgetConfig.config = {
141141
sendWithShiftEnter,
142142
stackMessages,
143143
unreadNotifications,
144144
enableCodeToolbar
145-
});
145+
};
146146
}
147147

148148
if (settingRegistry) {

0 commit comments

Comments
 (0)