From 916edf47d430fcd4a8067870760d4fcd22b607eb Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 5 May 2023 13:03:53 +0100 Subject: [PATCH] Handling last page removed --- packages/frontend-core/src/fetch/DataFetch.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/frontend-core/src/fetch/DataFetch.js b/packages/frontend-core/src/fetch/DataFetch.js index c49d8c29fb..cc931bfe06 100644 --- a/packages/frontend-core/src/fetch/DataFetch.js +++ b/packages/frontend-core/src/fetch/DataFetch.js @@ -369,10 +369,20 @@ export default class DataFetch { const currentNextCursor = cursors[pageNumber + 1] if (currentNextCursor != cursor) { + // If the current cursor changed, all the next pages need to be updated, so we mark them as stale cursors = cursors.slice(0, pageNumber + 1) cursors[pageNumber + 1] = cursor } + if (!rows.length && pageNumber > 0) { + this.store.update($store => ({ + ...$store, + loading: false, + cursors: cursors.slice(0, pageNumber), + })) + return await this.prevPage() + } + this.store.update($store => ({ ...$store, rows,