Skip to content

Commit

Permalink
fix: Move getSettings() to extension enable function
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanViknar committed May 11, 2024
1 parent 0abdd86 commit 8fd68cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {

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

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

// Disconnect settings change handler
if (this.settingsHandler !== undefined) {
this.settings.disconnect(this.settingsHandler);
this.settings!.disconnect(this.settingsHandler);
this.settingsHandler = undefined;
}

this.settings = undefined;
}

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

applySettings() {
logIfEnabled(LogType.Debug, 'Applying settings...');
updateLogging(this.settings.get_boolean('logging-enabled'));
updateLogging(this.settings!.get_boolean('logging-enabled'));
this.indicator!.applyPosition();
}
}
4 changes: 2 additions & 2 deletions src/indicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ export default GObject.registerClass(
// @ts-expect-error Panel boxes do not exist in the type definitions.
right: Main.panel._rightBox as St.BoxLayout,
};
const position = this.extension.settings.get_int('position');
const index = this.extension.settings.get_int('position-number');
const position = this.extension.settings!.get_int('position');
const index = this.extension.settings!.get_int('position-number');

Main.panel._addToPanelBox(
this.extension.uuid,
Expand Down

0 comments on commit 8fd68cb

Please sign in to comment.