add ContactsModel

This commit is contained in:
marlon-erler
2026-09-27 02:22:13 +02:00
parent bc399c4c7c
commit 01fefa0bb0
2 changed files with 22 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
import StorageModel, {StorageModelSubPaths} from "./storageModel";
export default class ContactsModel {
private getContactPath = (contactId: string): string[] => {
return [StorageModelSubPaths.ContactsModel, contactId];
}
loadContacts = (): [string, string][] => {
const contactIds: string[] = this.storageModel.list([StorageModelSubPaths.ContactsModel]);
const contacts: [string, string][] = contactIds.map(id => [id, this.storageModel.read(this.getContactPath(id))]);
return contacts;
}
storeContact = (id: string, name: string) => {
const path = this.getContactPath(id);
this.storageModel.write(path, name)
}
constructor(public storageModel: StorageModel) {
}
}
+1
View File
@@ -267,6 +267,7 @@ export enum StorageModelSubPaths {
ConnectionModel = "connection", ConnectionModel = "connection",
NotificationModel = "notifications", NotificationModel = "notifications",
SettingsModel = "settings", SettingsModel = "settings",
ContactsModel = "contacts",
} }
export const filePaths = { export const filePaths = {