Browse Source

[editor] Show rows in reverse order for streaming results in the ResultTable component

Johan Åhlén 4 years ago
parent
commit
12f475369c

+ 14 - 2
desktop/core/src/desktop/js/apps/editor/components/result/ResultTable.vue

@@ -166,13 +166,25 @@
             }));
           }
 
+          const addRows = (existingRows: ResultRow[], newRows: ResultRow[]) => {
+            newRows.forEach(row => {
+              if (streaming.value) {
+                existingRows.unshift(row);
+              } else {
+                existingRows.push(row);
+              }
+            });
+          };
+
           if (refresh) {
-            rows.value = executionResult.rows;
+            const existingRows: ResultRow[] = [];
+            addRows(existingRows, executionResult.rows);
+            rows.value = existingRows;
           } else if (
             executionResult.lastRows.length &&
             rows.value.length !== executionResult.rows.length
           ) {
-            rows.value.push(...executionResult.lastRows);
+            addRows(rows.value, executionResult.lastRows);
           }
         }
       };