add readonly keyword where applicable - AI

This commit is contained in:
marlon-erler
2026-04-13 10:58:21 +00:00
parent 8a5b54b03c
commit 1a8d40b184
27 changed files with 164 additions and 164 deletions
+51 -51
View File
@@ -2246,7 +2246,7 @@
};
// src/ViewModel/Global/coreViewModel.ts
var CoreViewModel = class _CoreViewModel {
var CoreViewModel = class {
// init
constructor(storageModel2, settingsModel2, connectionModel2, chatListModel2, fileTransferModel2) {
this.storageModel = storageModel2;
@@ -2254,7 +2254,7 @@
this.connectionModel = connectionModel2;
this.chatListModel = chatListModel2;
this.fileTransferModel = fileTransferModel2;
this.BUILD = "Build 26.04.12.C";
this.BUILD = "Build 26.04.13.A";
// CONTEXT
this.contextStack = /* @__PURE__ */ new Map();
this.logContexts = () => {
@@ -2275,7 +2275,6 @@
this.logContexts();
};
this.handleKeyDown = (e) => {
if (!_CoreViewModel.checkIsKeystroke(e)) return;
const contexts = this.contexts;
while (contexts.length > 0) {
const currentContext = contexts.pop();
@@ -6067,6 +6066,7 @@
this.presentedModal.value = 4 /* TransferDataInput */;
};
this.prepareReceivingData = () => {
if (this.cannotPrepareToReceive.value == true) return;
this.presentedModal.value = 5 /* ReceptionDisplay */;
this.filePathsReceived.clear();
const transferData = {
@@ -6592,6 +6592,54 @@
// src/Model/Global/settingsModel.ts
var SettingsModel = class _SettingsModel {
// init
constructor(storageModel2) {
this.setName = (newValue) => {
this.username = newValue;
this.storeSetting("username", newValue);
};
this.setFirstDayOfWeek = (newValue) => {
this.firstDayOfWeek = newValue;
this.storeSetting("firstDayOfWeek", newValue);
};
this.setLanguage = (newValue) => {
this.language = newValue;
this.storeSetting("language", newValue);
};
this.setTheme = (newValue) => {
this.theme = newValue;
this.storeSetting("theme", newValue);
};
// load
this.readSetting = (pathName) => {
const path = StorageModel.getPath(
"settings" /* SettingsModel */,
filePaths.settingsModel[pathName]
);
return this.storageModel.read(path);
};
this.loadUsername = () => {
const content = this.readSetting("username");
this.username = content ?? "";
};
this.loadFirstDayofWeek = () => {
const content = this.readSetting("firstDayOfWeek");
this.firstDayOfWeek = content ?? "0";
};
this.loadLanguage = () => {
const content = this.readSetting("language");
this.language = content ?? _SettingsModel.getSystemLanguage();
};
this.loadTheme = () => {
const content = this.readSetting("theme");
this.theme = content ?? "system" /* System */;
};
this.storageModel = storageModel2;
this.loadUsername();
this.loadFirstDayofWeek();
this.loadLanguage();
this.loadTheme();
}
// storage
storeSetting(pathName, value) {
const path = StorageModel.getPath(
@@ -6600,54 +6648,6 @@
);
this.storageModel.write(path, value);
}
setName(newValue) {
this.username = newValue;
this.storeSetting("username", newValue);
}
setFirstDayOfWeek(newValue) {
this.firstDayOfWeek = newValue;
this.storeSetting("firstDayOfWeek", newValue);
}
setLanguage(newValue) {
this.language = newValue;
this.storeSetting("language", newValue);
}
setTheme(newValue) {
this.theme = newValue;
this.storeSetting("theme", newValue);
}
// load
readSetting(pathName) {
const path = StorageModel.getPath(
"settings" /* SettingsModel */,
filePaths.settingsModel[pathName]
);
return this.storageModel.read(path);
}
loadUsername() {
const content = this.readSetting("username");
this.username = content ?? "";
}
loadFirstDayofWeek() {
const content = this.readSetting("firstDayOfWeek");
this.firstDayOfWeek = content ?? "0";
}
loadLanguage() {
const content = this.readSetting("language");
this.language = content ?? _SettingsModel.getSystemLanguage();
}
loadTheme() {
const content = this.readSetting("theme");
this.theme = content ?? "system" /* System */;
}
// init
constructor(storageModel2) {
this.storageModel = storageModel2;
this.loadUsername();
this.loadFirstDayofWeek();
this.loadLanguage();
this.loadTheme();
}
static getSystemLanguage() {
switch (navigator.language.substring(0, 2)) {
case "de":
+4 -4
View File
@@ -10,12 +10,12 @@ import SettingsModel from "../Global/settingsModel";
import { v4 } from "uuid";
export default class ChatListModel {
storageModel: StorageModel;
settingsModel: SettingsModel;
connectionModel: ConnectionModel;
readonly storageModel: StorageModel;
readonly settingsModel: SettingsModel;
readonly connectionModel: ConnectionModel;
// data
chatModels: Set<ChatModel> = new Set<ChatModel>();
chatModels = new Set<ChatModel>();
// handlers
messageHandler = (data: Message): void => {
+14 -14
View File
@@ -26,21 +26,21 @@ import SettingsModel from "../Global/settingsModel";
import { v4 } from "uuid";
export default class ChatModel {
connectionModel: ConnectionModel;
storageModel: StorageModel;
settingsModel: SettingsModel;
chatListModel: ChatListModel;
readonly connectionModel: ConnectionModel;
readonly storageModel: StorageModel;
readonly settingsModel: SettingsModel;
readonly chatListModel: ChatListModel;
fileModel: FileModel;
readonly fileModel: FileModel;
// data
id: string;
readonly id: string;
info: ChatInfo;
color: Colors;
chatMessageHandlerManager: HandlerManager<ChatMessage> =
new HandlerManager();
reactionHandlerManager: HandlerManager<ChatMessageReaction> =
readonly reactionHandlerManager: HandlerManager<ChatMessageReaction> =
new HandlerManager();
get secondaryChannels(): string[] {
@@ -459,12 +459,12 @@ export enum ChatMessageStatuses {
}
export interface ChatMessage extends ValidObject {
id: string;
readonly id: string;
channel: string;
sender: string;
readonly channel: string;
readonly sender: string;
body: string;
dateSent: string;
readonly dateSent: string;
status: ChatMessageStatuses;
@@ -473,9 +473,9 @@ export interface ChatMessage extends ValidObject {
export interface ChatMessageReaction
extends ValidObject, FileContent<"reaction"> {
messageId: string;
sender: string;
content: ReactionSymbols | string;
readonly messageId: string;
readonly sender: string;
readonly content: ReactionSymbols | string;
isDeleting: boolean;
}
+7 -7
View File
@@ -15,16 +15,16 @@ import StorageModel from "../Global/storageModel";
import { v4 } from "uuid";
export default class BoardsAndTasksModel {
storageModel: StorageModel;
settingsModel: SettingsModel;
chatModel: ChatModel;
fileModel: FileModel;
readonly storageModel: StorageModel;
readonly settingsModel: SettingsModel;
readonly chatModel: ChatModel;
readonly fileModel: FileModel;
calendarModel: CalendarModel;
readonly calendarModel: CalendarModel;
// data
boardHandlerManager = new HandlerManager<BoardInfoFileContent>();
taskHandlerManager = new HandlerManager<TaskFileContent>();
readonly boardHandlerManager = new HandlerManager<BoardInfoFileContent>();
readonly taskHandlerManager = new HandlerManager<TaskFileContent>();
// paths
getBasePath = (): string[] => {
+9 -9
View File
@@ -7,9 +7,9 @@ import StorageModel from "../Global/storageModel";
import { TaskFileContent } from "./boardsAndTasksModel";
export default class CalendarModel {
storageModel: StorageModel;
fileModel: FileModel;
settingsModel: SettingsModel;
readonly storageModel: StorageModel;
readonly fileModel: FileModel;
readonly settingsModel: SettingsModel;
// paths
getBasePath = (): string[] => {
@@ -155,12 +155,12 @@ export enum CalendarModelSubPaths {
// types
export interface MonthGrid<T> {
offset: number;
firstDayOfWeek: number;
isCurrentMonth: boolean;
readonly offset: number;
readonly firstDayOfWeek: number;
readonly isCurrentMonth: boolean;
year: number;
month: number;
readonly year: number;
readonly month: number;
days: { [date: string]: T };
readonly days: { [date: string]: T };
}
+8 -8
View File
@@ -18,11 +18,11 @@ import SettingsModel from "../Global/settingsModel";
import { v4 } from "uuid";
export default class FileModel {
storageModel: StorageModel;
settingsModel: SettingsModel;
readonly storageModel: StorageModel;
readonly settingsModel: SettingsModel;
chatModel: ChatModel;
boardsAndTasksModel: BoardsAndTasksModel;
readonly chatModel: ChatModel;
readonly boardsAndTasksModel: BoardsAndTasksModel;
// paths
getBasePath = (): string[] => {
@@ -193,11 +193,11 @@ export enum FileModelSubPath {
// types
export interface FileContent<T extends string>
extends ValidObject, StringEntryObject {
fileId: string;
fileContentId: string;
creationDate: string;
readonly fileId: string;
readonly fileContentId: string;
readonly creationDate: string;
type: T;
readonly type: T;
}
// references
+6 -6
View File
@@ -6,8 +6,8 @@ import StorageModel, { StorageModelSubPaths, filePaths } from "./storageModel";
import UDNFrontend, { Message } from "udn-frontend";
export default class ConnectionModel {
udn: UDNFrontend;
storageModel: StorageModel;
readonly udn: UDNFrontend;
readonly storageModel: StorageModel;
reconnectInterval: number | undefined = undefined;
shouldAttemptReconnect: boolean = false;
@@ -20,10 +20,10 @@ export default class ConnectionModel {
return this.udn.ws?.url;
}
connectionChangeHandlerManager = new HandlerManager<void>();
messageHandlerManager = new HandlerManager<Message>();
messageSentHandlerManager = new HandlerManager<ChatMessage>();
channelsToSubscribe = new Set<string>();
readonly connectionChangeHandlerManager = new HandlerManager<void>();
readonly messageHandlerManager = new HandlerManager<Message>();
readonly messageSentHandlerManager = new HandlerManager<ChatMessage>();
readonly channelsToSubscribe = new Set<string>();
// handlers
handleMessage = (data: Message): void => {
+7 -7
View File
@@ -14,15 +14,15 @@ import StorageModel from "./storageModel";
import { checkMatchesObjectStructure } from "../Utility/typeSafety";
export default class FileTransferModel {
storageModel: StorageModel;
connectionModel: ConnectionModel;
readonly storageModel: StorageModel;
readonly connectionModel: ConnectionModel;
static READY_MESSAGE = "ready";
// data
transferData: TransferData | undefined = undefined;
fileHandlerManager = new HandlerManager<string>();
readyToSendHandlerManager = new HandlerManager<boolean>();
transferData: TransferData | undefined;
readonly fileHandlerManager = new HandlerManager<string>();
readonly readyToSendHandlerManager = new HandlerManager<boolean>();
direction: TransferDirections = TransferDirections.Send;
// general
@@ -140,8 +140,8 @@ export default class FileTransferModel {
}
export interface TransferData {
channel: string;
key: string;
readonly channel: string;
readonly key: string;
}
export interface FileData {
+1 -1
View File
@@ -3,7 +3,7 @@
import StorageModel, { StorageModelSubPaths, filePaths } from "./storageModel";
export default class SettingsModel {
storageModel: StorageModel;
readonly storageModel: StorageModel;
// data
username: string;
+4 -4
View File
@@ -14,7 +14,7 @@ export default class ChatListViewModel {
notificationViewModel: NotificationViewModel;
// data
chatIndexManager = new IndexManager<ChatViewModel>(
readonly chatIndexManager = new IndexManager<ChatViewModel>(
(chatViewModel: ChatViewModel) =>
chatViewModel.settingsPageViewModel.primaryChannel.value,
);
@@ -96,9 +96,9 @@ export default class ChatListViewModel {
// init
constructor(
public coreViewModel: CoreViewModel,
public settingsViewModel: SettingsViewModel,
public connectionViewModel: ConnectionViewModel,
public readonly coreViewModel: CoreViewModel,
public readonly settingsViewModel: SettingsViewModel,
public readonly connectionViewModel: ConnectionViewModel,
) {
this.notificationViewModel = new NotificationViewModel(this);
+2 -2
View File
@@ -123,8 +123,8 @@ export default class ChatMessageViewModel {
// init
constructor(
public coreViewModel: CoreViewModel,
public messagePageViewModel: MessagePageViewModel,
public readonly coreViewModel: CoreViewModel,
public readonly messagePageViewModel: MessagePageViewModel,
chatMessage: ChatMessage,
sentByUser: boolean,
) {
+6 -6
View File
@@ -145,12 +145,12 @@ export default class ChatViewModel extends ContextHost<ChatPageTypes> {
// init
constructor(
public coreViewModel: CoreViewModel,
public chatModel: ChatModel,
public settingsViewModel: SettingsViewModel,
public notificationViewModel: NotificationViewModel,
public connectionViewModel: ConnectionViewModel,
public chatListViewModel: ChatListViewModel,
public readonly coreViewModel: CoreViewModel,
public readonly chatModel: ChatModel,
public readonly settingsViewModel: SettingsViewModel,
public readonly notificationViewModel: NotificationViewModel,
public readonly connectionViewModel: ConnectionViewModel,
public readonly chatListViewModel: ChatListViewModel,
) {
super();
+1 -1
View File
@@ -87,7 +87,7 @@ export default class ConnectionViewModel {
};
// init
constructor(public coreViewModel: CoreViewModel) {
constructor(public readonly coreViewModel: CoreViewModel) {
this.updatePreviousAddresses();
coreViewModel.connectionModel.connectionChangeHandlerManager.addHandler(
+5 -5
View File
@@ -66,11 +66,11 @@ export default class CoreViewModel {
// init
constructor(
public storageModel: StorageModel,
public settingsModel: SettingsModel,
public connectionModel: ConnectionModel,
public chatListModel: ChatListModel,
public fileTransferModel: FileTransferModel,
public readonly storageModel: StorageModel,
public readonly settingsModel: SettingsModel,
public readonly connectionModel: ConnectionModel,
public readonly chatListModel: ChatListModel,
public readonly fileTransferModel: FileTransferModel,
) {
this.translations =
allTranslations[settingsModel.language] || allTranslations.en;
@@ -13,7 +13,7 @@ import CoreViewModel, { Context } from "./coreViewModel";
import { CommonKeys } from "../../View/keystrokes";
export default class FileTransferViewModel extends Context {
contextDebugDescription: string = "transfer";
contextDebugDescription = "transfer";
// state
presentedModal: React.State<FileTransferModals | undefined> =
@@ -172,7 +172,7 @@ export default class FileTransferViewModel extends Context {
};
// init
constructor(public coreViewModel: CoreViewModel) {
constructor(public readonly coreViewModel: CoreViewModel) {
super();
this.coreViewModel.fileTransferModel.fileHandlerManager.addHandler(
@@ -76,7 +76,7 @@ export default class NotificationViewModel {
};
// init
constructor(public chatListViewModel: ChatListViewModel) {}
constructor(public readonly chatListViewModel: ChatListViewModel) {}
// util
static createNotification(message: ChatMessage): Notification {
+2 -2
View File
@@ -5,7 +5,7 @@ import { Languages, ThemeSettings } from "../../Model/Global/settingsModel";
import { CommonKeys } from "../../View/keystrokes";
export default class SettingsViewModel extends Context {
contextDebugDescription: string = "settings";
contextDebugDescription = "settings";
// state
username: React.State<string> = new React.State("");
@@ -72,7 +72,7 @@ export default class SettingsViewModel extends Context {
};
// init
constructor(public coreViewModel: CoreViewModel) {
constructor(public readonly coreViewModel: CoreViewModel) {
super();
this.username.value = coreViewModel.settingsModel.username;
+1 -1
View File
@@ -65,7 +65,7 @@ export default class StorageViewModel extends Context {
};
// init
constructor(public coreViewModel: CoreViewModel) {
constructor(public readonly coreViewModel: CoreViewModel) {
super();
this.selectedFileName = React.createProxyState(
+6 -6
View File
@@ -16,7 +16,7 @@ import TaskViewModel from "./taskViewModel";
import { CommonKeys } from "../../View/keystrokes";
export default class BoardViewModel extends TaskContainingPageViewModel {
contextDebugDescription: string = "board";
contextDebugDescription = "board";
// state
name: React.State<string> = new React.State("");
@@ -247,11 +247,11 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
// init
constructor(
public coreViewModel: CoreViewModel,
public chatViewModel: ChatViewModel,
public boardsAndTasksModel: BoardsAndTasksModel,
public taskPageViewModel: TaskPageViewModel,
public boardInfo: BoardInfoFileContent,
public readonly coreViewModel: CoreViewModel,
public readonly chatViewModel: ChatViewModel,
public readonly boardsAndTasksModel: BoardsAndTasksModel,
public readonly taskPageViewModel: TaskPageViewModel,
public readonly boardInfo: BoardInfoFileContent,
) {
super(coreViewModel, chatViewModel, boardsAndTasksModel);
+4 -4
View File
@@ -185,10 +185,10 @@ export default class CalendarPageViewModel extends TaskContainingPageViewModel {
// init
constructor(
public coreViewModel: CoreViewModel,
public chatViewModel: ChatViewModel,
public calendarModel: CalendarModel,
public boardsAndTasksModel: BoardsAndTasksModel,
public readonly coreViewModel: CoreViewModel,
public readonly chatViewModel: ChatViewModel,
public readonly calendarModel: CalendarModel,
public readonly boardsAndTasksModel: BoardsAndTasksModel,
) {
super(coreViewModel, chatViewModel, boardsAndTasksModel);
+5 -5
View File
@@ -9,11 +9,11 @@ export default class HomeViewModel extends Context {
contextDebugDescription = "home";
constructor(
public coreViewModel: CoreViewModel,
public settingsViewModel: SettingsViewModel,
public fileTransferViewModel: FileTransferViewModel,
public storageViewModel: StorageViewModel,
public connectionViewModel: ConnectionViewModel,
public readonly coreViewModel: CoreViewModel,
public readonly settingsViewModel: SettingsViewModel,
public readonly fileTransferViewModel: FileTransferViewModel,
public readonly storageViewModel: StorageViewModel,
public readonly connectionViewModel: ConnectionViewModel,
) {
super();
+2 -2
View File
@@ -127,8 +127,8 @@ export default class MessagePageViewModel extends Context {
// init
constructor(
public coreViewModel: CoreViewModel,
public chatViewModel: ChatViewModel,
public readonly coreViewModel: CoreViewModel,
public readonly chatViewModel: ChatViewModel,
) {
super();
+2 -2
View File
@@ -112,8 +112,8 @@ export default class SettingsPageViewModel extends Context {
// init
constructor(
public coreViewModel: CoreViewModel,
public chatViewModel: ChatViewModel,
public readonly coreViewModel: CoreViewModel,
public readonly chatViewModel: ChatViewModel,
) {
super();
@@ -11,7 +11,7 @@ import TaskViewModel from "./taskViewModel";
export default class TaskContainingPageViewModel extends Context {
// state
taskIndexManager = new IndexManager<TaskViewModel>(
readonly taskIndexManager = new IndexManager<TaskViewModel>(
(taskViewModel: TaskViewModel) => taskViewModel.sortingString,
);
@@ -56,9 +56,9 @@ export default class TaskContainingPageViewModel extends Context {
// init
constructor(
public coreViewModel: CoreViewModel,
public chatViewModel: ChatViewModel,
public boardsAndTasksModel: BoardsAndTasksModel,
public readonly coreViewModel: CoreViewModel,
public readonly chatViewModel: ChatViewModel,
public readonly boardsAndTasksModel: BoardsAndTasksModel,
) {
super();
}
+5 -5
View File
@@ -11,10 +11,10 @@ import { IndexManager } from "../../Model/Utility/utility";
import { CommonKeys } from "../../View/keystrokes";
export default class TaskPageViewModel extends ContextHost<string> {
contextDebugDescription: string = "task-page";
contextDebugDescription = "task-page";
// data
boardIndexManager = new IndexManager<BoardViewModel>(
readonly boardIndexManager = new IndexManager<BoardViewModel>(
(boardViewModel: BoardViewModel) => boardViewModel.name.value,
);
@@ -162,9 +162,9 @@ export default class TaskPageViewModel extends ContextHost<string> {
// init
constructor(
public coreViewModel: CoreViewModel,
public chatViewModel: ChatViewModel,
public boardsAndTasksModel: BoardsAndTasksModel,
public readonly coreViewModel: CoreViewModel,
public readonly chatViewModel: ChatViewModel,
public readonly boardsAndTasksModel: BoardsAndTasksModel,
) {
super();
+4 -4
View File
@@ -210,10 +210,10 @@ export default class TaskViewModel extends Context {
// init
constructor(
public coreViewModel: CoreViewModel,
public chatViewModel: ChatViewModel,
public boardsAndTasksModel: BoardsAndTasksModel,
public containingModel: TaskContainingPageViewModel,
public readonly coreViewModel: CoreViewModel,
public readonly chatViewModel: ChatViewModel,
public readonly boardsAndTasksModel: BoardsAndTasksModel,
public readonly containingModel: TaskContainingPageViewModel,
public task: TaskFileContent,
) {
super();
@@ -19,7 +19,7 @@ export default class TaskPropertyBulkChangeViewModel {
});
};
setValue: (newValue: string, taskViewModel: TaskViewModel) => void = () => {};
setValue: (newValue: string, taskViewModel: TaskViewModel) => void;
// init
constructor(