diff --git a/src/app/common/modals/modals.tsx b/src/app/common/modals/modals.tsx index f19c4cb0a..7b15fda7c 100644 --- a/src/app/common/modals/modals.tsx +++ b/src/app/common/modals/modals.tsx @@ -558,26 +558,33 @@ class CreateRemoteConnModal extends React.Component<{}, {}> { kwargs["connectmode"] = this.tempConnectMode.get(); kwargs["visual"] = "1"; kwargs["submit"] = "1"; - let model = this.model; let prtn = GlobalCommandRunner.createRemote(cname, kwargs, false); prtn.then((crtn) => { if (crtn.success) { + this.model.setRecentConnAdded(true); + this.model.closeModal(); + let crRtn = GlobalCommandRunner.screenSetRemote(cname, true, false); crRtn.then((crcrtn) => { if (crcrtn.success) { return; } mobx.action(() => { - this.errorStr.set(crcrtn.error ?? null); + this.errorStr.set(crcrtn.error); })(); }); return; } mobx.action(() => { - this.errorStr.set(crtn.error ?? null); + this.errorStr.set(crtn.error); })(); }); - model.seRecentConnAdded(true); + } + + @boundMethod + handleClose(): void { + this.model.closeModal(); + this.model.setRecentConnAdded(false); } @boundMethod @@ -795,7 +802,7 @@ class CreateRemoteConnModal extends React.Component<{}, {}> {
Error: {this.getErrorStr()}
- + ); } @@ -812,7 +819,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> { } @mobx.computed - get selectedRemote(): T.RemoteType { + getSelectedRemote(): T.RemoteType { const selectedRemoteId = this.model.selectedRemoteId.get(); return GlobalModel.getRemote(selectedRemoteId); } @@ -827,7 +834,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> { } componentDidUpdate() { - if (this.selectedRemote == null || this.selectedRemote.archived) { + if (this.getSelectedRemote() == null || this.getSelectedRemote().archived) { this.model.deSelectRemote(); } } @@ -891,7 +898,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> { @boundMethod clickArchive(): void { - if (this.selectedRemote && this.selectedRemote.status == "connected") { + if (this.getSelectedRemote() && this.getSelectedRemote().status == "connected") { GlobalModel.showAlert({ message: "Cannot delete when connected. Disconnect and try again." }); return; } @@ -903,21 +910,22 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> { if (!confirm) { return; } - if (this.selectedRemote) { - GlobalCommandRunner.archiveRemote(this.selectedRemote.remoteid); + if (this.getSelectedRemote()) { + GlobalCommandRunner.archiveRemote(this.getSelectedRemote().remoteid); } + GlobalModel.modalsModel.popModal(); }); } @boundMethod clickReinstall(): void { - GlobalCommandRunner.installRemote(this.selectedRemote?.remoteid); + GlobalCommandRunner.installRemote(this.getSelectedRemote().remoteid); } @boundMethod handleClose(): void { this.model.closeModal(); - this.model.seRecentConnAdded(false); + this.model.setRecentConnAdded(false); } renderInstallStatus(remote: T.RemoteType): any { @@ -1078,7 +1086,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> { } render() { - let remote = this.selectedRemote; + let remote = this.getSelectedRemote(); if (remote == null) { return null; @@ -1092,7 +1100,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> { return ( - +
@@ -1167,7 +1175,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
- +
); } diff --git a/src/model/model.ts b/src/model/model.ts index ce2d49a88..323f6db84 100644 --- a/src/model/model.ts +++ b/src/model/model.ts @@ -2926,8 +2926,11 @@ class RemotesModel { return this.recentConnAddedState.get(); } - seRecentConnAdded(value: boolean) { - this.recentConnAddedState.set(value); + @boundMethod + setRecentConnAdded(value: boolean) { + mobx.action(() => { + this.recentConnAddedState.set(value); + })(); } deSelectRemote(): void { @@ -2939,6 +2942,7 @@ class RemotesModel { openReadModal(remoteId: string): void { mobx.action(() => { + this.setRecentConnAdded(false); this.selectedRemoteId.set(remoteId); this.remoteEdit.set(null); GlobalModel.modalsModel.pushModal(appconst.VIEW_REMOTE); @@ -3724,8 +3728,8 @@ class Model { this.remotes.clear(); } this.updateRemotes(update.remotes); + // This code's purpose is to show view remote connection modal when a new connection is added if (update.remotes && update.remotes.length && this.remotesModel.recentConnAddedState.get()) { - GlobalModel.remotesModel.closeModal(); GlobalModel.remotesModel.openReadModal(update.remotes![0].remoteid); } }