From 00449f3f83411482fe3626578709f61033390c3d Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 14 Sep 2024 00:42:17 +0800 Subject: [PATCH] :bug: Fix Too many elements --- devtools_options.yaml | 3 ++- lib/providers/database/services/messages.dart | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/devtools_options.yaml b/devtools_options.yaml index 2bc8e05..9876d76 100644 --- a/devtools_options.yaml +++ b/devtools_options.yaml @@ -1,4 +1,5 @@ description: This file stores settings for Dart & Flutter DevTools. documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states extensions: - - provider: true \ No newline at end of file + - provider: true + - drift: true \ No newline at end of file diff --git a/lib/providers/database/services/messages.dart b/lib/providers/database/services/messages.dart index f814a49..7bb9d98 100644 --- a/lib/providers/database/services/messages.dart +++ b/lib/providers/database/services/messages.dart @@ -155,7 +155,8 @@ class MessagesFetchingProvider extends GetxController { final database = Get.find().database; final lastOne = await (database.select(database.localMessageEventTable) ..where((x) => x.channelId.equals(channel.id)) - ..orderBy([(t) => OrderingTerm.desc(t.id)])) + ..orderBy([(t) => OrderingTerm.desc(t.id)]) + ..limit(1)) .getSingleOrNull(); final data = await fetchRemoteEvents( @@ -169,7 +170,7 @@ class MessagesFetchingProvider extends GetxController { ); if (data != null) { await database.batch((batch) { - batch.insertAll( + batch.insertAllOnConflictUpdate( database.localMessageEventTable, data.$1.map((x) => LocalMessageEventTableCompanion( id: Value(x.id),