Compare commits

...

3 Commits

Author SHA1 Message Date
Red Adaya 407bddeb33 fix conflicts 2024-03-14 09:10:03 +08:00
Red Adaya 4c33d24a7b close modals on ECS 2024-03-12 09:31:35 +08:00
Red Adaya f850e3b728 remove clearmodals mothed as it's no longer needed 2024-03-12 09:03:46 +08:00
7 changed files with 32 additions and 38 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ class AlertModal extends React.Component<{}, {}> {
<Markdown text={message?.message ?? ""} extraClassName="bottom-margin" />
</If>
<If condition={!message?.markdown}>{message?.message}</If>
<If condition={message.confirmflag}>
<If condition={message?.confirmflag}>
<Checkbox
onChange={this.handleDontShowAgain}
label={"Don't show me this again"}
+1 -1
View File
@@ -206,7 +206,7 @@ class BookmarksModel {
}
handleDocKeyDown(e: any): void {
let waveEvent = adaptFromReactOrNativeKeyEvent(e);
const waveEvent = adaptFromReactOrNativeKeyEvent(e);
if (checkKeyPressed(waveEvent, "Escape")) {
e.preventDefault();
if (this.editingBookmark.get() != null) {
+10
View File
@@ -3,6 +3,7 @@
import * as mobx from "mobx";
import { Model } from "./model";
import { checkKeyPressed, adaptFromReactOrNativeKeyEvent } from "@/util/keyutil";
class ClientSettingsViewModel {
globalModel: Model;
@@ -21,6 +22,15 @@ class ClientSettingsViewModel {
this.globalModel.activeMainView.set("clientsettings");
})();
}
handleDocKeyDown(e: any): void {
const waveEvent = adaptFromReactOrNativeKeyEvent(e);
if (checkKeyPressed(waveEvent, "Escape")) {
e.preventDefault();
this.closeView();
return;
}
}
}
export { ClientSettingsViewModel };
+10
View File
@@ -3,6 +3,7 @@
import * as mobx from "mobx";
import { Model } from "./model";
import { checkKeyPressed, adaptFromReactOrNativeKeyEvent } from "@/util/keyutil";
class ConnectionsViewModel {
globalModel: Model;
@@ -21,6 +22,15 @@ class ConnectionsViewModel {
this.globalModel.activeMainView.set("connections");
})();
}
handleDocKeyDown(e: any): void {
const waveEvent = adaptFromReactOrNativeKeyEvent(e);
if (checkKeyPressed(waveEvent, "Escape")) {
e.preventDefault();
this.closeView();
return;
}
}
}
export { ConnectionsViewModel };
+1 -1
View File
@@ -291,7 +291,7 @@ class HistoryViewModel {
}
handleDocKeyDown(e: any): void {
let waveEvent = adaptFromReactOrNativeKeyEvent(e);
const waveEvent = adaptFromReactOrNativeKeyEvent(e);
if (checkKeyPressed(waveEvent, "Escape")) {
e.preventDefault();
this.closeView();
+2 -1
View File
@@ -18,10 +18,11 @@ class ModalsModel {
}
}
popModal() {
popModal(callback?: () => void) {
mobx.action(() => {
this.store.pop();
})();
callback && callback();
}
}
+7 -34
View File
@@ -372,7 +372,6 @@ class Model {
cancelAlert(): void {
mobx.action(() => {
this.alertMessage.set(null);
this.modalsModel.popModal();
})();
if (this.alertPromiseResolver != null) {
this.alertPromiseResolver(false);
@@ -493,7 +492,7 @@ class Model {
if (this.alertMessage.get() != null) {
if (checkKeyPressed(waveEvent, "Escape")) {
e.preventDefault();
this.cancelAlert();
this.modalsModel.popModal(() => this.cancelAlert());
return;
}
if (checkKeyPressed(waveEvent, "Enter")) {
@@ -503,6 +502,10 @@ class Model {
}
return;
}
if (checkKeyPressed(waveEvent, "Escape") && this.modalsModel.store.length > 0) {
this.modalsModel.popModal();
return;
}
if (this.activeMainView.get() == "bookmarks") {
this.bookmarksModel.handleDocKeyDown(e);
}
@@ -510,10 +513,10 @@ class Model {
this.historyViewModel.handleDocKeyDown(e);
}
if (this.activeMainView.get() == "connections") {
this.historyViewModel.handleDocKeyDown(e);
this.connectionViewModel.handleDocKeyDown(e);
}
if (this.activeMainView.get() == "clientsettings") {
this.historyViewModel.handleDocKeyDown(e);
this.clientSettingsViewModel.handleDocKeyDown(e);
} else {
if (checkKeyPressed(waveEvent, "Escape")) {
e.preventDefault();
@@ -521,9 +524,6 @@ class Model {
this.showSessionView();
return;
}
if (this.clearModals()) {
return;
}
const inputModel = this.inputModel;
inputModel.toggleInfoMsg();
if (inputModel.inputMode.get() != null) {
@@ -643,33 +643,6 @@ class Model {
return screen.getTermWrap(line.lineid);
}
clearModals(): boolean {
let didSomething = false;
mobx.action(() => {
if (this.screenSettingsModal.get()) {
this.screenSettingsModal.set(null);
didSomething = true;
}
if (this.sessionSettingsModal.get()) {
this.sessionSettingsModal.set(null);
didSomething = true;
}
if (this.screenSettingsModal.get()) {
this.screenSettingsModal.set(null);
didSomething = true;
}
if (this.clientSettingsModal.get()) {
this.clientSettingsModal.set(false);
didSomething = true;
}
if (this.lineSettingsModal.get()) {
this.lineSettingsModal.set(null);
didSomething = true;
}
})();
return didSomething;
}
restartWaveSrv(): void {
getApi().restartWaveSrv();
}