correct type issues

This commit is contained in:
marlon-erler
2026-09-09 00:04:27 +02:00
parent 4631730f02
commit 839e887d85
24 changed files with 511 additions and 437 deletions
+3 -3
View File
@@ -11,9 +11,9 @@ import {
export default class ChatMessageViewModel {
// data
chatMessage: ChatMessage;
channel: string;
sender: string;
dateSent: string;
channel: string = "";
sender: string = "";
dateSent: string = "";
body: React.State<string> = new React.State("");
inlineReply: ChatMessageViewModel | undefined = undefined;
status: React.State<ChatMessageStatuses | any> = new React.State<any>(
+2 -2
View File
@@ -143,14 +143,14 @@ export default class ChatViewModel extends ContextHost<ChatPageTypes> {
// init
constructor(
public readonly coreViewModel: CoreViewModel,
readonly coreViewModel: CoreViewModel,
public readonly chatModel: ChatModel,
public readonly settingsViewModel: SettingsViewModel,
public readonly notificationViewModel: NotificationViewModel,
public readonly connectionViewModel: ConnectionViewModel,
public readonly chatListViewModel: ChatListViewModel,
) {
super("chat");
super("chat", coreViewModel);
// page viewModels
this.calendarViewModel = new CalendarPageViewModel(
Binary file not shown.
+12 -5
View File
@@ -9,7 +9,7 @@ import ConnectionModel from "../../Model/Global/connectionModel";
import ChatListModel from "../../Model/Chat/chatListModel";
export default class CoreViewModel {
readonly BUILD = "Build 26.09.06.A";
readonly BUILD = "Build 26.09.09.A";
translations: Translations;
@@ -40,7 +40,8 @@ export default class CoreViewModel {
return;
while (this.contexts.length > 0) {
const currentContext: Context = this.context;
const currentContext: Context|undefined= this.context;
if (!currentContext) return;
currentContext.handleContextClose(fromHistoryEvent);
this.contextStack.delete(currentContext.contextId);
if (currentContext.contextId == contextId) break;
@@ -53,7 +54,7 @@ export default class CoreViewModel {
const contexts: Context[] = this.contexts;
while (contexts.length > 0) {
const currentContext: Context | undefined = contexts.pop();
if (!currentContext) contexts;
if (!currentContext) return;
const isHandled: boolean = currentContext.handleKeystroke(e);
if (isHandled == true) break;
}
@@ -102,6 +103,7 @@ export default class CoreViewModel {
document.body.addEventListener("keydown", this.handleKeyDown);
window.onpopstate = () => {
if (!this.context) return;
this.closeContext(this.context.contextId, true);
};
@@ -142,7 +144,6 @@ export class Context {
}
export class ContextHost<T> extends Context {
coreViewModel: CoreViewModel;
contexts = new Map<T, Context>();
currentContext = new React.State<Context | undefined>(undefined);
@@ -169,8 +170,10 @@ export class ContextHost<T> extends Context {
updateContexts = (): void => {
if (this.isOpen == false) return;
const selection = this.contextSelection;
if (!selection) return;
const selectedContext: Context | undefined = this.contexts.get(
this.contextSelection,
selection
);
if (!selectedContext) return;
if (selectedContext != this.currentContext.value) {
@@ -180,4 +183,8 @@ export class ContextHost<T> extends Context {
this.coreViewModel.context = selectedContext;
this.currentContext.value = selectedContext;
};
constructor(contextDebugDescription: string, public coreViewModel: CoreViewModel) {
super(contextDebugDescription);
}
}
@@ -54,7 +54,7 @@ export default class FileTransferViewModel extends Context {
exportKey: React.State<string> = new React.State("");
exportKeyConfirmation: React.State<string> = new React.State("");
importedFile: React.State<File | undefined> = new React.State(undefined);
importedFile: React.State<File | undefined> = new React.State<File | undefined>(undefined);
importedFileString: React.State<string> = new React.State("");
importKey: React.State<string> = new React.State("");
isImportKeyCorrect: React.State<boolean> = new React.State(true);
@@ -158,6 +158,7 @@ export default class FileTransferViewModel extends Context {
if (!input) return;
if (!(input instanceof HTMLInputElement)) return;
if (!input.files) return;
const file = input.files[0];
this.importedFile.value = file;
};
@@ -170,6 +171,7 @@ export default class FileTransferViewModel extends Context {
reader.readAsText(file, "utf8");
reader.onload = () => {
const result = reader.result;
if (!result) return;
this.importedFileString.value = result.toString();
this.showImportDecryptDataModal();
};
@@ -35,7 +35,7 @@ export default class NotificationViewModel {
};
openNotification = () => {
const notification: Notification = this.marquee.value;
const notification: Notification|undefined = this.marquee.value;
if (notification == undefined) return;
const chat = [
@@ -44,6 +44,7 @@ export default class NotificationViewModel {
(chat) =>
chat.chatModel.unwrappedPrimaryChannel == notification.chat,
);
if (!chat) return;
chat.open();
chat.openPage(ChatPageTypes.Messages);
};
@@ -55,7 +56,8 @@ export default class NotificationViewModel {
return this.stopLoop();
}
const notification: Notification = this.messagesInMarquee.shift();
const notification: Notification|undefined = this.messagesInMarquee.shift();
if (!notification) return;
this.seenMessageIds.delete(notification.messageId);
this.marquee.value = notification;
};
+3 -3
View File
@@ -9,14 +9,14 @@ export default class SettingsViewModel extends Context {
usernameInput: React.State<string> = new React.State("");
isShowingSettingsModal: React.State<boolean> = new React.State(false);
selectedModalPage: React.State<SettingsModalPages | undefined> =
new React.State(undefined);
new React.State<SettingsModalPages | undefined>(undefined);
requiresReload = new React.State<boolean>(false);
firstDayOfWeek: React.State<string> = new React.State("0");
language: React.State<Languages | string> = new React.State(
language: React.State<Languages | string> = new React.State<Languages | string>(
Languages.English,
);
theme: React.State<ThemeSettings | string> = new React.State(
theme: React.State<ThemeSettings | string> = new React.State<ThemeSettings | string>(
ThemeSettings.System,
);
+1 -1
View File
@@ -23,7 +23,7 @@ export default class StorageViewModel extends Context {
const path: string[] = StorageModel.stringToPathComponents(
this.selectedPath.value,
);
const content: string | undefined =
const content: string | null =
this.coreViewModel.storageModel.read(path);
return (
(content ?? this.coreViewModel.translations.storage.notAFile) ||
+1 -1
View File
@@ -68,7 +68,7 @@ export default class MessagePageViewModel extends Context {
);
};
setReply = (chatMessageViewModel: ChatMessageViewModel): void => {
setReply = (chatMessageViewModel: ChatMessageViewModel|undefined): void => {
this.replyingMessage.value = chatMessageViewModel;
this.setFocus();
};
+2 -2
View File
@@ -167,11 +167,11 @@ export default class TaskPageViewModel extends ContextHost<string> {
// init
constructor(
public readonly coreViewModel: CoreViewModel,
readonly coreViewModel: CoreViewModel,
public readonly chatViewModel: ChatViewModel,
public readonly boardsAndTasksModel: BoardsAndTasksModel,
) {
super("task-page");
super("task-page", coreViewModel);
this.loadData(); // needed for board options in calendar