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
+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);
}