Skip to content

Commit 8fd68cb

Browse files
committed
fix: Move getSettings() to extension enable function
1 parent 0abdd86 commit 8fd68cb

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/extension.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222

2323
// ----------------------- Extension -----------------------
2424
export default class NoiseclapperExtension extends Extension {
25-
public settings = this.getSettings();
25+
public settings?: Gio.Settings;
2626
private bluetoothClient?: GnomeBluetooth.Client;
2727
private indicator?: InstanceType<typeof NoiseclapperIndicator>;
2828
private settingsHandler?: Gio.SettingsBindFlags;
@@ -43,6 +43,7 @@ export default class NoiseclapperExtension extends Extension {
4343
Main.panel.addToStatusArea(this.uuid, this.indicator);
4444

4545
// Apply settings and position
46+
this.settings = this.getSettings();
4647
this.settingsHandler = this.settings.connect(
4748
'changed',
4849
this.applySettings.bind(this),
@@ -65,9 +66,11 @@ export default class NoiseclapperExtension extends Extension {
6566

6667
// Disconnect settings change handler
6768
if (this.settingsHandler !== undefined) {
68-
this.settings.disconnect(this.settingsHandler);
69+
this.settings!.disconnect(this.settingsHandler);
6970
this.settingsHandler = undefined;
7071
}
72+
73+
this.settings = undefined;
7174
}
7275

7376
signalHandler(signal: string) {
@@ -100,7 +103,7 @@ export default class NoiseclapperExtension extends Extension {
100103

101104
applySettings() {
102105
logIfEnabled(LogType.Debug, 'Applying settings...');
103-
updateLogging(this.settings.get_boolean('logging-enabled'));
106+
updateLogging(this.settings!.get_boolean('logging-enabled'));
104107
this.indicator!.applyPosition();
105108
}
106109
}

src/indicator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ export default GObject.registerClass(
180180
// @ts-expect-error Panel boxes do not exist in the type definitions.
181181
right: Main.panel._rightBox as St.BoxLayout,
182182
};
183-
const position = this.extension.settings.get_int('position');
184-
const index = this.extension.settings.get_int('position-number');
183+
const position = this.extension.settings!.get_int('position');
184+
const index = this.extension.settings!.get_int('position-number');
185185

186186
Main.panel._addToPanelBox(
187187
this.extension.uuid,

0 commit comments

Comments
 (0)