From fb78274fb800a41884b16fdb6f178507047f84c4 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Tue, 30 Aug 2022 12:40:11 -0400 Subject: [PATCH] Fixes "last page" issue on the graph Adds additional logging --- src/webviews/apps/plus/graph/graph.tsx | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/webviews/apps/plus/graph/graph.tsx b/src/webviews/apps/plus/graph/graph.tsx index 3443d75..fb2f8df 100644 --- a/src/webviews/apps/plus/graph/graph.tsx +++ b/src/webviews/apps/plus/graph/graph.tsx @@ -108,16 +108,28 @@ export class GraphApp extends App { let previousRowsLength = previousRows.length; const newRowsLength = params.rows.length; + this.log( + `${this.appName}.onMessageReceived(${msg.id}:${msg.method}): paging in ${newRowsLength} rows into existing ${previousRowsLength} rows at ${params.paging.startingCursor} (last existing row: ${lastSha})`, + ); + rows = []; // Preallocate the array to avoid reallocations rows.length = previousRowsLength + newRowsLength; if (params.paging.startingCursor !== lastSha) { + this.log( + `${this.appName}.onMessageReceived(${msg.id}:${msg.method}): searching for ${params.paging.startingCursor} in existing rows`, + ); + let i = 0; let row; for (row of previousRows) { rows[i++] = row; if (row.sha === params.paging.startingCursor) { + this.log( + `${this.appName}.onMessageReceived(${msg.id}:${msg.method}): found ${params.paging.startingCursor} in existing rows`, + ); + previousRowsLength = i; if (previousRowsLength !== previousRows.length) { @@ -138,7 +150,16 @@ export class GraphApp extends App { rows[previousRowsLength + i] = params.rows[i]; } } else { - rows = params.rows; + this.log( + `${this.appName}.onMessageReceived(${msg.id}:${msg.method}): setting to ${params.rows.length} rows`, + ); + + if (params.rows.length === 0) { + rows = this.state.rows; + } else { + // TODO@eamodio I'm not sure there is a case for this, but didn't wan't to remove it yet + rows = params.rows; + } } this.setState({