improve keystrokes, cleanup

This commit is contained in:
marlon-erler
2026-04-15 12:47:10 +00:00
parent ed8f523a89
commit 091c666ccc
31 changed files with 324 additions and 245 deletions
+1 -1
View File
@@ -252,7 +252,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
if (!fromHistoryEvent) return;
this.taskPageViewModel.storeLastUsedBoard();
}
};
// init
constructor(
+25 -6
View File
@@ -27,6 +27,7 @@ export default class MessagePageViewModel extends Context {
undefined,
);
composingMessage = new React.State<string>("");
focusSetter = new React.State(null);
// guards
cannotSendMessage: React.State<boolean>;
@@ -40,14 +41,11 @@ export default class MessagePageViewModel extends Context {
};
sendMessageFromBody = (body: string): void => {
let replyId: string|undefined = undefined;
let replyId: string | undefined = undefined;
if (this.replyingMessage.value) {
replyId = this.replyingMessage.value.chatMessage.id;
}
this.chatViewModel.chatModel.sendMessage(
body,
replyId,
);
this.chatViewModel.chatModel.sendMessage(body, replyId);
this.replyingMessage.value = undefined;
};
@@ -72,6 +70,16 @@ export default class MessagePageViewModel extends Context {
);
};
setReply = (chatMessageViewModel: ChatMessageViewModel): void => {
this.replyingMessage.value = chatMessageViewModel;
this.setFocus();
};
resetReply = (): void => {
this.replyingMessage.value = undefined;
this.setFocus();
};
// view
showChatMessage = (chatMessage: ChatMessage): void => {
const chatMessageViewModel = new ChatMessageViewModel(
@@ -123,6 +131,10 @@ export default class MessagePageViewModel extends Context {
this.searchViewModel.search("");
};
setFocus = (): void => {
this.focusSetter.callSubscriptions();
};
// load
loadData = (): void => {
this.chatMessageViewModels.clear();
@@ -168,8 +180,15 @@ export default class MessagePageViewModel extends Context {
// keystrokes
this.registerKeyStroke(CommonKeys.Filter, this.showFilterModal);
this.registerKeyStroke(CommonKeys.CloseOrCancel, this.hideFilterModal);
this.registerKeyStroke(CommonKeys.CloseOrCancel, () => {
if (this.isFilterModalOpen.value == true) {
this.hideFilterModal();
} else {
this.replyingMessage.value = undefined;
}
});
this.registerKeyStroke(CommonKeys.Reset, this.resetFilter);
this.registerKeyStroke(CommonKeys.Create, this.setFocus);
this.chatViewModel.registerContext(ChatPageTypes.Messages, this);
}
+3 -2
View File
@@ -114,10 +114,11 @@ export default class TaskPageViewModel extends ContextHost<string> {
closeBoard = (): void => {
this.closeCurrentContext();
}
};
handleBoardClosed = (boardViewModel: BoardViewModel): void => {
if (boardViewModel.boardInfo.fileId != this.selectedBoardId.value) return;
if (boardViewModel.boardInfo.fileId != this.selectedBoardId.value)
return;
this.selectedBoardId.value = undefined;
this.chatViewModel.resetColor();
+2 -3
View File
@@ -8,9 +8,8 @@ import { localeCompare, padZero } from "../../Model/Utility/utility";
import ChatViewModel from "../Chat/chatViewModel";
import CoreViewModel, { Context } from "../Global/coreViewModel";
import TaskContainingPageViewModel from "./taskContainingPageViewModel";
import { allowDrag } from "../../View/utility";
import { v4 } from "uuid";
import { CommonKeys } from "../../View/keystrokes";
import { ViewController } from "../../View/viewController";
export default class TaskViewModel extends Context {
// util
@@ -63,7 +62,7 @@ export default class TaskViewModel extends Context {
// methods
dragStart = (event: DragEvent): void => {
allowDrag(event);
ViewController.allowDrag(event);
this.coreViewModel.draggedObject.value = this;
};