Skip to content

Commit 6f78c11

Browse files
committed
just ignore studio actions if nothing to do
1 parent 38fb0eb commit 6f78c11

File tree

1 file changed

+34
-36
lines changed

1 file changed

+34
-36
lines changed

src/commands/studio.ts

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -250,44 +250,42 @@ class StudioActions {
250250
title: `Executing user action: ${action.label}`,
251251
},
252252
() => {
253-
return new Promise((resolve, reject) => {
254-
this.api
255-
.actionQuery(query, parameters)
256-
.then(async (data) => {
257-
if (action.save) {
258-
await this.processSaveFlag(action.save);
259-
}
260-
if (!afterUserAction) {
261-
outputConsole(data.console);
262-
}
263-
if (!data.result.content.length) {
264-
// nothing to-do, just ignore it
265-
return resolve();
266-
}
267-
const actionToProcess = data.result.content.pop();
253+
return this.api
254+
.actionQuery(query, parameters)
255+
.then(async (data) => {
256+
if (action.save) {
257+
await this.processSaveFlag(action.save);
258+
}
259+
if (!afterUserAction) {
260+
outputConsole(data.console);
261+
}
262+
if (!data.result.content.length) {
263+
// nothing to-do, just ignore it
264+
return;
265+
}
266+
const actionToProcess = data.result.content.pop();
268267

269-
// CSP pages should not have a progress bar
270-
if (actionToProcess.action === 2) {
271-
resolve();
272-
}
273-
return actionToProcess;
274-
})
275-
.then(this.processUserAction)
276-
.then((answer) => {
277-
if (answer) {
278-
return answer.msg || answer.msg === ""
268+
// CSP pages should not have a progress bar
269+
if (actionToProcess.action === 2) {
270+
return;
271+
}
272+
return actionToProcess;
273+
})
274+
.then(
275+
(actionToProcess) =>
276+
actionToProcess &&
277+
this.processUserAction(actionToProcess).then((answer) =>
278+
answer && (answer.msg || answer.msg === "")
279279
? this.userAction(action, true, answer.answer, answer.msg, type)
280-
: this.userAction(action, true, answer, "", type);
281-
}
282-
})
283-
.then(() => resolve())
284-
.catch((err) => {
285-
console.log(err);
286-
outputChannel.appendLine(`Studio Action "${action.label}" not supported`);
287-
outputChannel.show();
288-
return reject();
289-
});
290-
});
280+
: this.userAction(action, true, answer, "", type)
281+
)
282+
)
283+
.catch((err) => {
284+
console.log(err);
285+
outputChannel.appendLine(`Studio Action "${action.label}" not supported`);
286+
outputChannel.show();
287+
return Promise.reject();
288+
});
291289
}
292290
);
293291
}

0 commit comments

Comments
 (0)