From c739a498f19668bf480b6b806d32bef4e84d3b2b Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Wed, 12 May 2021 17:51:54 +0200 Subject: [PATCH] :bug: Fix ordering when auto refreshing (#1761) * Fix ordering when auto refreshing * Fix ordering for current executinos as well --- packages/cli/src/Server.ts | 1 + packages/editor-ui/src/components/ExecutionsList.vue | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index cbe43697f3..fb4523af3c 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -1732,6 +1732,7 @@ class App { } ); } + returnData.sort((a, b) => parseInt(b.id, 10) - parseInt(a.id, 10)); return returnData; } diff --git a/packages/editor-ui/src/components/ExecutionsList.vue b/packages/editor-ui/src/components/ExecutionsList.vue index d576c6898b..e0e129a737 100644 --- a/packages/editor-ui/src/components/ExecutionsList.vue +++ b/packages/editor-ui/src/components/ExecutionsList.vue @@ -438,7 +438,8 @@ export default mixins( this.$store.commit('setActiveExecutions', results[1]); - const alreadyPresentExecutionIds = this.finishedExecutions.map(exec => exec.id); + // execution IDs are typed as string, int conversion is necessary so we can order. + const alreadyPresentExecutionIds = this.finishedExecutions.map(exec => parseInt(exec.id, 10)); let lastId = 0; const gaps = [] as number[]; for(let i = results[0].results.length - 1; i >= 0; i--) { @@ -459,7 +460,7 @@ export default mixins( // Check new results from end to start // Add new items accordingly. - const executionIndex = alreadyPresentExecutionIds.indexOf(currentItem.id); + const executionIndex = alreadyPresentExecutionIds.indexOf(currentId); if (executionIndex !== -1) { // Execution that we received is already present. @@ -477,7 +478,7 @@ export default mixins( // Find the correct position to place this newcomer let j; for (j = this.finishedExecutions.length - 1; j >= 0; j--) { - if (currentItem.id < this.finishedExecutions[j].id) { + if (currentId < parseInt(this.finishedExecutions[j].id, 10)) { this.finishedExecutions.splice(j + 1, 0, currentItem); break; }