add usedid to model

This commit is contained in:
marlon-erler
2026-09-27 01:46:55 +02:00
parent 9622c196cd
commit 42421e31ee
2 changed files with 14 additions and 2 deletions
+13 -2
View File
@@ -1,5 +1,4 @@
// cleanup: Phase A import {UUID} from "../../react";
import StorageModel, { StorageModelSubPaths, filePaths } from "./storageModel"; import StorageModel, { StorageModelSubPaths, filePaths } from "./storageModel";
export default class SettingsModel { export default class SettingsModel {
@@ -7,6 +6,7 @@ export default class SettingsModel {
// data // data
username: string = ""; username: string = "";
userid: string = "";
firstDayOfWeek: string = ""; firstDayOfWeek: string = "";
language: string = ""; language: string = "";
theme: string = ""; theme: string = "";
@@ -23,6 +23,11 @@ export default class SettingsModel {
this.storageModel.write(path, value); this.storageModel.write(path, value);
}; };
readonly setId = (newValue: string): void => {
this.userid = newValue;
this.storeSetting("userid", newValue);
};
readonly setName = (newValue: string): void => { readonly setName = (newValue: string): void => {
this.username = newValue; this.username = newValue;
this.storeSetting("username", newValue); this.storeSetting("username", newValue);
@@ -54,6 +59,11 @@ export default class SettingsModel {
return this.storageModel.read(path); return this.storageModel.read(path);
}; };
readonly loadID = (): void => {
const content: string | null = this.readSetting("userid");
this.userid = content ?? UUID();
};
readonly loadUsername = (): void => { readonly loadUsername = (): void => {
const content: string | null = this.readSetting("username"); const content: string | null = this.readSetting("username");
this.username = content ?? ""; this.username = content ?? "";
@@ -78,6 +88,7 @@ export default class SettingsModel {
constructor(storageModel: StorageModel) { constructor(storageModel: StorageModel) {
this.storageModel = storageModel; this.storageModel = storageModel;
this.loadID();
this.loadUsername(); this.loadUsername();
this.loadFirstDayofWeek(); this.loadFirstDayofWeek();
this.loadLanguage(); this.loadLanguage();
+1
View File
@@ -306,6 +306,7 @@ export const filePaths = {
settingsModel: { settingsModel: {
username: ["user-name"], username: ["user-name"],
userid: ["user-id"],
firstDayOfWeek: ["first-day-of-week"], firstDayOfWeek: ["first-day-of-week"],
language: ["language"], language: ["language"],
theme: ["theme"], theme: ["theme"],