2024-07-20 00:22:53 +02:00
|
|
|
// this file is responsible for all settings.
|
|
|
|
|
|
2026-04-08 14:02:12 +00:00
|
|
|
import StorageModel, { StorageModelSubPaths, filePaths } from "./storageModel";
|
2024-07-20 00:22:53 +02:00
|
|
|
|
|
|
|
|
export default class SettingsModel {
|
2026-04-01 08:29:39 +00:00
|
|
|
storageModel: StorageModel;
|
|
|
|
|
|
|
|
|
|
// data
|
|
|
|
|
username: string;
|
|
|
|
|
firstDayOfWeek: string;
|
|
|
|
|
|
|
|
|
|
// storage
|
|
|
|
|
setName(newValue: string): void {
|
|
|
|
|
this.username = newValue;
|
|
|
|
|
const path = StorageModel.getPath(
|
2026-04-08 14:02:12 +00:00
|
|
|
StorageModelSubPaths.SettingsModel,
|
2026-04-01 08:29:39 +00:00
|
|
|
filePaths.settingsModel.username,
|
|
|
|
|
);
|
|
|
|
|
this.storageModel.write(path, newValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setFirstDayOfWeek(newValue: string): void {
|
|
|
|
|
this.firstDayOfWeek = newValue;
|
|
|
|
|
const path = StorageModel.getPath(
|
2026-04-08 14:02:12 +00:00
|
|
|
StorageModelSubPaths.SettingsModel,
|
2026-04-01 08:29:39 +00:00
|
|
|
filePaths.settingsModel.firstDayOfWeek,
|
|
|
|
|
);
|
|
|
|
|
this.storageModel.write(path, newValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// load
|
|
|
|
|
loadUsernam(): void {
|
|
|
|
|
const path = StorageModel.getPath(
|
2026-04-08 14:02:12 +00:00
|
|
|
StorageModelSubPaths.SettingsModel,
|
2026-04-01 08:29:39 +00:00
|
|
|
filePaths.settingsModel.username,
|
|
|
|
|
);
|
|
|
|
|
const content = this.storageModel.read(path);
|
|
|
|
|
this.username = content ?? "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadFirstDayofWeek(): void {
|
|
|
|
|
const path = StorageModel.getPath(
|
2026-04-08 14:02:12 +00:00
|
|
|
StorageModelSubPaths.SettingsModel,
|
2026-04-01 08:29:39 +00:00
|
|
|
filePaths.settingsModel.firstDayOfWeek,
|
|
|
|
|
);
|
|
|
|
|
const content = this.storageModel.read(path);
|
|
|
|
|
this.firstDayOfWeek = content ?? "0";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// init
|
|
|
|
|
constructor(storageModel: StorageModel) {
|
|
|
|
|
this.storageModel = storageModel;
|
|
|
|
|
|
|
|
|
|
this.loadUsernam();
|
|
|
|
|
this.loadFirstDayofWeek();
|
|
|
|
|
}
|
2024-07-20 00:22:53 +02:00
|
|
|
}
|