From 7f71922988d9c86d9023e183b6d5732965850cda Mon Sep 17 00:00:00 2001 From: "Francesco Bozzotta (aka xFr4xx)" Date: Tue, 30 Jan 2024 21:59:38 +0100 Subject: [PATCH] fix scroll data --- apps/demo/src/app/database/database.page.ts | 2 +- libs/database/src/lib/store/database.state.ts | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/apps/demo/src/app/database/database.page.ts b/apps/demo/src/app/database/database.page.ts index 34189eb..dea57a5 100644 --- a/apps/demo/src/app/database/database.page.ts +++ b/apps/demo/src/app/database/database.page.ts @@ -18,7 +18,7 @@ export class DatabasePageComponent { ) { this.taskState.setDatabaseId('demo'); this.taskState.setCollectionId('tasks'); - this.taskState.load([Query.limit(100)]); + this.taskState.load([Query.limit(50)]); } public async create() { diff --git a/libs/database/src/lib/store/database.state.ts b/libs/database/src/lib/store/database.state.ts index 83c62b7..44c7582 100644 --- a/libs/database/src/lib/store/database.state.ts +++ b/libs/database/src/lib/store/database.state.ts @@ -71,14 +71,8 @@ export abstract class SioDatabaseState< if (collectionId) this.setCollectionId(collectionId); if (queries) this.setQueries(queries); if (this.snapshot.databaseId && this.snapshot.collectionId) { - let queries: string[] = []; if (this.snapshot.queries) { - const { ...get_queries } = this.snapshot.queries; - queries = get_queries; - if (this.snapshot.remoteIndex) - queries.push( - Query.cursorAfter(this.snapshot.remoteIndex as string), - ); + if (this.snapshot.remoteIndex) queries= [...this.snapshot.queries,Query.cursorAfter(this.snapshot.remoteIndex as string), ] } const documents = >( await this.sioDatabaseService.query( @@ -88,13 +82,13 @@ export abstract class SioDatabaseState< ) ); if (this.snapshot.remoteIndex) { - console.error(documents.documents) this.addEntitiesMany(documents.documents); } else { this.setEntitiesMany(documents.documents); } this.setRemoteTotals(documents.total); this.setLocalTotals(this.snapshot.ids.length); + console.error(documents.documents.pop()!.$id!); this.setRemoteIndex(documents.documents.pop()!.$id!); } return true;