Skip to content

Commit

Permalink
Merge pull request #288 from tareqimbasher/fix/280-results-clear-on-b…
Browse files Browse the repository at this point in the history
…ackground-scripts

Fixes #280 bug results getting cleared when switching tabs and then back to a script that is still running in the background
  • Loading branch information
tareqimbasher authored Nov 12, 2024
2 parents b73b936 + d05ab71 commit 59de220
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {watch} from "@aurelia/runtime-html";
import {KeyCode, System, Util} from "@common";
import {ChannelInfo, IIpcGateway, ScriptStatus} from "@application";
import {ExcelExportDialog} from "../excel-export/excel-export-dialog";
Expand Down Expand Up @@ -40,15 +39,6 @@ export class ResultsView extends OutputViewBase {
this.addDisposable(() => this.txtUserInput.removeEventListener("keydown", userInputKeyHandler));
}

@watch<ResultsView>(vm => vm.model.environment.status)
private scriptStatusChanged(newStatus: ScriptStatus, oldStatus: ScriptStatus) {
this.model.inputRequest = null;

if (oldStatus !== "Running" && newStatus === "Running") {
this.model.resultsDumpContainer.clearOutput(true);
}
}

private async exportOutputToExcel() {
if (!this.model) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import {watch} from "@aurelia/runtime-html";
import {ScriptStatus} from "@application";
import {OutputViewBase} from "../output-view-base";

export class SqlView extends OutputViewBase {
@watch<SqlView>(vm => vm.model.environment.status)
private scriptStatusChanged(newStatus: ScriptStatus, oldStatus: ScriptStatus) {
if (oldStatus !== "Running" && newStatus === "Running") {
this.model.sqlDumpContainer.clearOutput(true);
}
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {PLATFORM} from "aurelia";
import {watch} from "@aurelia/runtime-html";
import {
EnvironmentPropertyChangedEvent,
HtmlErrorScriptOutput,
HtmlRawScriptOutput,
HtmlResultsScriptOutput,
Expand All @@ -14,6 +15,7 @@ import {
PromptUserForInputCommand,
ScriptEnvironment,
ScriptOutputEmittedEvent,
ScriptStatus,
Settings,
ShortcutIds
} from "@application";
Expand Down Expand Up @@ -57,6 +59,7 @@ export class OutputPane extends Pane {
}

public attached() {
this.listenForScriptStatusChanges();
this.listenForOutputMessages();

if (!this.isWindow) {
Expand All @@ -76,6 +79,21 @@ export class OutputPane extends Pane {
PLATFORM.queueMicrotask(() => this.activatePaneIfApplicable());
}

private listenForScriptStatusChanges() {
this.disposables.add(
this.eventBus.subscribeToServer(EnvironmentPropertyChangedEvent, msg => {
if (msg.propertyName == "Status" && (msg.newValue as ScriptStatus) == "Running") {
const model = this.outputModels.get(msg.scriptId);
if (model) {
model.inputRequest = null;
model.resultsDumpContainer.clearOutput(true);
model.sqlDumpContainer.clearOutput(true);
}
}
})
);
}

private listenForOutputMessages() {
this.disposables.add(
this.eventBus.subscribeToServer(ScriptOutputEmittedEvent, msg => {
Expand Down

0 comments on commit 59de220

Please sign in to comment.