improve keystrokes, cleanup
This commit is contained in:
@@ -82,12 +82,12 @@ export default class ChatMessageViewModel {
|
||||
};
|
||||
|
||||
reply = (): void => {
|
||||
this.messagePageViewModel.replyingMessage.value = this;
|
||||
this.messagePageViewModel.setReply(this);
|
||||
this.hideInfoModal();
|
||||
};
|
||||
cancelReply = (): void => {
|
||||
if (this.messagePageViewModel.replyingMessage.value != this) return;
|
||||
this.messagePageViewModel.replyingMessage.value = undefined;
|
||||
this.messagePageViewModel.setReply(undefined);
|
||||
};
|
||||
|
||||
// view
|
||||
@@ -131,7 +131,10 @@ export default class ChatMessageViewModel {
|
||||
this.status.value = this.chatMessage.status;
|
||||
|
||||
if (this.chatMessage.inlineReplyId) {
|
||||
this.inlineReply = this.messagePageViewModel.chatMessageViewModels.value.get(this.chatMessage.inlineReplyId);
|
||||
this.inlineReply =
|
||||
this.messagePageViewModel.chatMessageViewModels.value.get(
|
||||
this.chatMessage.inlineReplyId,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ export default class ChatViewModel extends ContextHost<ChatPageTypes> {
|
||||
this.chatListViewModel.openChat(this);
|
||||
//this.selectedPage.callSubscriptions();
|
||||
};
|
||||
|
||||
|
||||
openPage = (page: ChatPageTypes): void => {
|
||||
this.closeCurrentContext();
|
||||
this.selectedPage.value = page;
|
||||
@@ -142,7 +142,7 @@ export default class ChatViewModel extends ContextHost<ChatPageTypes> {
|
||||
|
||||
handleContextClose = (): void => {
|
||||
this.chatListViewModel.closeChat();
|
||||
}
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(
|
||||
|
||||
@@ -27,7 +27,10 @@ export default class CoreViewModel {
|
||||
history.pushState({ id: context.contextId }, "");
|
||||
}
|
||||
|
||||
closeContext = (contextId: string, fromHistoryEvent: boolean = false): void => {
|
||||
closeContext = (
|
||||
contextId: string,
|
||||
fromHistoryEvent: boolean = false,
|
||||
): void => {
|
||||
if (
|
||||
!this.contexts
|
||||
.map((context) => context.contextId)
|
||||
@@ -81,7 +84,7 @@ export default class CoreViewModel {
|
||||
|
||||
window.onpopstate = () => {
|
||||
this.closeContext(this.context.contextId, true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// util
|
||||
@@ -110,7 +113,7 @@ export class Context {
|
||||
this.keystrokes.set(key, fn);
|
||||
};
|
||||
|
||||
constructor(public contextDebugDescription: string) { }
|
||||
constructor(public contextDebugDescription: string) {}
|
||||
}
|
||||
|
||||
export class ContextHost<T> extends Context {
|
||||
|
||||
@@ -171,7 +171,7 @@ export default class FileTransferViewModel extends Context {
|
||||
|
||||
handleContextClose = (): void => {
|
||||
this.presentedModal.value = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(public readonly coreViewModel: CoreViewModel) {
|
||||
|
||||
@@ -71,7 +71,7 @@ export default class SettingsViewModel extends Context {
|
||||
if (this.requiresReload.value == true) {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(public readonly coreViewModel: CoreViewModel) {
|
||||
@@ -102,10 +102,7 @@ export default class SettingsViewModel extends Context {
|
||||
);
|
||||
|
||||
// keystrokes
|
||||
this.registerKeyStroke(
|
||||
CommonKeys.CloseOrCancel,
|
||||
this.close,
|
||||
);
|
||||
this.registerKeyStroke(CommonKeys.CloseOrCancel, this.close);
|
||||
}
|
||||
|
||||
static generateThemeMedia(): MediaQueryList {
|
||||
|
||||
@@ -65,7 +65,7 @@ export default class StorageViewModel extends Context {
|
||||
return;
|
||||
}
|
||||
this.isShowingStorageModal.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(public readonly coreViewModel: CoreViewModel) {
|
||||
|
||||
@@ -252,7 +252,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
||||
|
||||
if (!fromHistoryEvent) return;
|
||||
this.taskPageViewModel.storeLastUsedBoard();
|
||||
}
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user