♻️ 使用 Drift 作为本地数据库 #3
@ -1,4 +1,5 @@
|
|||||||
description: This file stores settings for Dart & Flutter DevTools.
|
description: This file stores settings for Dart & Flutter DevTools.
|
||||||
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
||||||
extensions:
|
extensions:
|
||||||
- provider: true
|
- provider: true
|
||||||
|
- drift: true
|
@ -155,7 +155,8 @@ class MessagesFetchingProvider extends GetxController {
|
|||||||
final database = Get.find<DatabaseProvider>().database;
|
final database = Get.find<DatabaseProvider>().database;
|
||||||
final lastOne = await (database.select(database.localMessageEventTable)
|
final lastOne = await (database.select(database.localMessageEventTable)
|
||||||
..where((x) => x.channelId.equals(channel.id))
|
..where((x) => x.channelId.equals(channel.id))
|
||||||
..orderBy([(t) => OrderingTerm.desc(t.id)]))
|
..orderBy([(t) => OrderingTerm.desc(t.id)])
|
||||||
|
..limit(1))
|
||||||
.getSingleOrNull();
|
.getSingleOrNull();
|
||||||
|
|
||||||
final data = await fetchRemoteEvents(
|
final data = await fetchRemoteEvents(
|
||||||
@ -169,7 +170,7 @@ class MessagesFetchingProvider extends GetxController {
|
|||||||
);
|
);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
await database.batch((batch) {
|
await database.batch((batch) {
|
||||||
batch.insertAll(
|
batch.insertAllOnConflictUpdate(
|
||||||
database.localMessageEventTable,
|
database.localMessageEventTable,
|
||||||
data.$1.map((x) => LocalMessageEventTableCompanion(
|
data.$1.map((x) => LocalMessageEventTableCompanion(
|
||||||
id: Value(x.id),
|
id: Value(x.id),
|
||||||
|
Loading…
Reference in New Issue
Block a user