implement contacts with messaging

This commit is contained in:
marlon-erler
2026-09-27 03:01:43 +02:00
parent c5d61a5790
commit a9fba4646d
8 changed files with 118 additions and 98 deletions
+13 -5
View File
@@ -3,22 +3,30 @@ import * as React from "../../react";
export default class ContactListViewModel {
// state
contacts: React.MapState<ContactViewModel> = new React.MapState();
contacts: Map<string, ContactViewModel> = new Map();
// main
updateContact = (id: string, name: string): void => {
if (this.contacts.value.has(id)) {
this.contacts.value.get(id)!.name.value = name;
return;
updateContact = (id: string, name: string): ContactViewModel => {
const match = this.contacts.get(id);
if (match) {
match.name.value = name;
return match;
}
const vm = new ContactViewModel(id, name);
this.contacts.set(id, vm);
return vm;
}
handleContact = (contact: [string, string]): void => {
this.updateContact(...contact);
}
unwrapContact = (id: string, knownName: string): ContactViewModel => {
if (this.contacts.has(id))
return this.contacts.get(id)!
return this.updateContact(id, knownName);
}
// load
loadData = (): void => {
const contacts: [string, string][] = this.contactListModel.loadContacts();
+2 -2
View File
@@ -1,7 +1,7 @@
import CoreViewModel, { Context } from "./coreViewModel";
import * as React from "../../react";
import { CommonKeys } from "../../View/keystrokes";
import { Languages, ThemeSettings } from "../../Model/Global/settingsModel";
import SettingsModel, { Languages, ThemeSettings } from "../../Model/Global/settingsModel";
export default class SettingsViewModel extends Context {
// state
@@ -126,7 +126,7 @@ export default class SettingsViewModel extends Context {
};
// init
constructor(public readonly coreViewModel: CoreViewModel) {
constructor(public readonly coreViewModel: CoreViewModel, public readonly settingsModel: SettingsModel) {
super("settings");
this.username.value = coreViewModel.settingsModel.username;