Skip to content

Commit d616b65

Browse files
committed
moved deprecated functions into settings component, so it's usage is at least confined to this one component
1 parent 1a51515 commit d616b65

File tree

4 files changed

+18
-29
lines changed

4 files changed

+18
-29
lines changed

webapp/src/app/components/dialogs/settings/settings.component.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ import { MatCheckbox } from '@angular/material/checkbox';
4343
MatOption,
4444
ColoredTextDirective,
4545
MatCheckbox,
46-
ImageSelectCardComponent
47-
]
46+
ImageSelectCardComponent,
47+
],
4848
})
4949
export class SettingsComponent implements OnInit {
5050
private ref = inject(OverlayRefControl);
@@ -78,7 +78,11 @@ export class SettingsComponent implements OnInit {
7878

7979
http.getMods().subscribe(mods => this.mods = mods);
8080
this.mod = this.sharedService.getSelectedMod();
81-
this.settings = JSON.parse(JSON.stringify(this.settingsService.getSettings()));
81+
82+
this.settings = {} as AppSettings;
83+
for (const [key, val] of Object.entries(this.settingsService.signalSettings())) {
84+
this.settings[key as keyof AppSettings] = val();
85+
}
8286
}
8387

8488
ngOnInit() {
@@ -119,7 +123,7 @@ export class SettingsComponent implements OnInit {
119123
this.folderFormControl.setErrors(null);
120124
} else {
121125
this.folderFormControl.setErrors({
122-
invalid: true
126+
invalid: true,
123127
});
124128
}
125129
}
@@ -129,10 +133,16 @@ export class SettingsComponent implements OnInit {
129133
this.electron.saveAssetsPath(this.folderFormControl.value);
130134
}
131135
this.sharedService.saveModSelect(this.mod);
132-
this.settingsService.updateSettings(this.settings);
136+
137+
const settings = this.settingsService.signalSettings();
138+
for (const [k, val] of Object.entries(this.settings)) {
139+
const key = k as keyof AppSettings;
140+
settings[key].set(val);
141+
}
142+
133143
this.close();
134144
const ref = this.snackBar.open('Changing the path requires to restart the editor', 'Restart', {
135-
duration: 6000
145+
duration: 6000,
136146
});
137147

138148
ref.onAction().subscribe(() => this.sharedService.relaunch());

webapp/src/app/components/widgets/event-widget/event-editor/editor/event-editor.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class EventEditorComponent implements OnChanges, OnInit {
8282
private copiedNode?: EventDisplay;
8383

8484
ngOnInit() {
85-
this.wrapText = this.settingsService.getSettings().wrapEventEditorLines;
85+
this.wrapText = this.settingsService.signalSettings().wrapEventEditorLines();
8686
}
8787

8888
ngOnChanges() {

webapp/src/app/services/phaser/BaseTileDrawer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export class BaseTileDrawer extends BaseObject {
243243

244244
let textColor = 'rgba(0,0,0,0.6)';
245245
let backgroundColor = 0xffffff;
246-
if (Globals.settingsService.getSettings().selectionBoxDark) {
246+
if (Globals.settingsService.signalSettings().selectionBoxDark()) {
247247
textColor = 'rgba(255,255,255,0.9)';
248248
backgroundColor = 0x333333;
249249
}

webapp/src/app/services/settings.service.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@ export class SettingsService {
2929
}
3030
}
3131

32-
/**
33-
* @deprecated Use signalSettings instead.
34-
*/
35-
getSettings(): Readonly<AppSettings> {
36-
const out = {} as AppSettings;
37-
for (const [key, val] of Object.entries(this.settings)) {
38-
out[key as keyof AppSettings] = val();
39-
}
40-
return out;
41-
}
42-
4332
signalSettings(): Signalify<AppSettings> {
4433
return this.settings;
4534
}
@@ -49,14 +38,4 @@ export class SettingsService {
4938
const val = loadedValue === null ? defaultValue : (loadedValue === 'true');
5039
return signal(val);
5140
}
52-
53-
/**
54-
* @deprecated set signals directly instead
55-
*/
56-
public updateSettings(newSettings: Partial<AppSettings>) {
57-
for (const [k, val] of Object.entries(newSettings)) {
58-
const key = k as keyof AppSettings;
59-
this.settings[key].set(val);
60-
}
61-
}
6241
}

0 commit comments

Comments
 (0)