Skip to content

Commit ff695c9

Browse files
committed
fix: centralize module instantiation using MODULE_FACTORIES to fix settings not showing
1 parent a307351 commit ff695c9

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/extension.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ import { Extension } from "@girs/gnome-shell/extensions/extension";
77
import type { Module } from "./module.ts";
88
import { MODULE_REGISTRY, type ModuleDefinition } from "./registry.ts";
99

10+
import { ThemeChanger } from "./modules/themeChanger.ts";
11+
import { Dock } from "./modules/dock.ts";
12+
import { NoOverview } from "./modules/noOverview.ts";
13+
import { PipOnTop } from "./modules/pipOnTop.ts";
14+
15+
const MODULE_FACTORIES: Record<string, () => Module> = {
16+
themeChanger: () => new ThemeChanger(),
17+
dock: () => new Dock(),
18+
noOverview: () => new NoOverview(),
19+
pipOnTop: () => new PipOnTop(),
20+
};
21+
1022
/**
1123
* Aurora Shell Extension
1224
*
@@ -30,7 +42,7 @@ export default class AuroraShellExtension extends Extension {
3042
private _initializeModules(): void {
3143
for (const def of MODULE_REGISTRY) {
3244
if (this._settings?.get_boolean(def.settingsKey)) {
33-
this._modules.set(def.key, def.create());
45+
this._modules.set(def.key, MODULE_FACTORIES[def.key]());
3446
}
3547
}
3648
}
@@ -63,7 +75,7 @@ export default class AuroraShellExtension extends Extension {
6375
if (enabled && !existing) {
6476
console.log(`Aurora Shell: Enabling module ${def.key}`);
6577
try {
66-
const module = def.create();
78+
const module = MODULE_FACTORIES[def.key]();
6779
module.enable();
6880
this._modules.set(def.key, module);
6981
} catch (e) {

src/registry.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
import { ThemeChanger } from "./modules/themeChanger.ts";
2-
import { Dock } from "./modules/dock.ts";
3-
import { NoOverview } from "./modules/noOverview.ts";
4-
import { PipOnTop } from "./modules/pipOnTop.ts";
5-
import type { Module } from "./module.ts";
6-
71
/**
82
* Module definition that includes both runtime and UI metadata
93
*/
@@ -12,8 +6,6 @@ export type ModuleDefinition = {
126
key: string;
137
/** GSettings schema key */
148
settingsKey: string;
15-
/** Factory function to create module instance */
16-
create: () => Module;
179
/** User-facing title for preferences UI */
1810
title: string;
1911
/** User-facing subtitle/description for preferences UI */
@@ -23,36 +15,32 @@ export type ModuleDefinition = {
2315
/**
2416
* Single source of truth for all available modules.
2517
* To add a new module:
26-
* 1. Import its class at the top
27-
* 2. Add one entry to this array
18+
* 1. Add one entry to this array
19+
* 2. Add a factory entry in extension.ts MODULE_FACTORIES
2820
* 3. Add corresponding key to gschema.xml
2921
*/
3022
export const MODULE_REGISTRY: ModuleDefinition[] = [
3123
{
3224
key: 'themeChanger',
3325
settingsKey: 'module-theme-changer',
34-
create: () => new ThemeChanger(),
3526
title: 'Theme Changer',
3627
subtitle: 'Monitors and synchronizes GNOME color scheme',
3728
},
3829
{
3930
key: 'dock',
4031
settingsKey: 'module-dock',
41-
create: () => new Dock(),
4232
title: 'Dock',
4333
subtitle: 'Custom dock with auto-hide and intellihide features',
4434
},
4535
{
4636
key: 'noOverview',
4737
settingsKey: 'module-no-overview',
48-
create: () => new NoOverview(),
4938
title: 'No Overview',
5039
subtitle: 'Disables the overview at startup',
5140
},
5241
{
5342
key: 'pipOnTop',
5443
settingsKey: 'module-pip-on-top',
55-
create: () => new PipOnTop(),
5644
title: 'Pip On Top',
5745
subtitle: 'Keeps Picture-in-Picture windows always on top',
5846
},

0 commit comments

Comments
 (0)