fix: persistence (#329)
* fix(llc): Save original passed persistence for client reconnection. Signed-off-by: Sahil Kumar <[email protected]> * fix(persistence): Check for empty channels before applying offset Signed-off-by: Sahil Kumar <[email protected]> * fix(llc): Remove debug logs Signed-off-by: Sahil Kumar <[email protected]> * fix(persistence): Reset isolate on successful disconnect Signed-off-by: Sahil Kumar <[email protected]> * use mutexes in persistence client * fix(persistence): use `super.updateChannelStates` Signed-off-by: Sahil Kumar <[email protected]> * fix(persistence): fix database multiple times creation. Signed-off-by: Sahil Kumar <[email protected]> Co-authored-by: Sahil Kumar <[email protected]>
This commit is contained in:
co-authored by
Sahil Kumar
parent
ca1f70948e
commit
9952265109
@@ -76,17 +76,21 @@ class SharedDB {
|
||||
/// [MoorChatDatabase.connect] created on a background isolate.
|
||||
///
|
||||
/// Generally used with [ConnectionMode.background].
|
||||
static Future<MoorChatDatabase> constructMoorChatDatabase(
|
||||
static MoorChatDatabase constructMoorChatDatabase(
|
||||
String userId, {
|
||||
bool logStatements = false,
|
||||
}) async {
|
||||
}) {
|
||||
final dbName = 'db_$userId';
|
||||
final isolate = await _createMoorIsolate(
|
||||
dbName,
|
||||
logStatements: logStatements,
|
||||
return MoorChatDatabase.connect(
|
||||
userId,
|
||||
DatabaseConnection.delayed(Future(() async {
|
||||
MoorIsolate isolate = await _createMoorIsolate(
|
||||
dbName,
|
||||
logStatements: logStatements,
|
||||
);
|
||||
return isolate.connect();
|
||||
})),
|
||||
);
|
||||
final connection = await isolate.connect();
|
||||
return MoorChatDatabase.connect(userId, isolate, connection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:moor/backends.dart';
|
||||
import 'package:stream_chat_persistence/src/db/moor_chat_database.dart';
|
||||
import 'package:stream_chat_persistence/stream_chat_persistence.dart';
|
||||
|
||||
/// A Helper class to construct new instances of [MoorChatDatabase]
|
||||
@@ -5,7 +7,7 @@ class SharedDB {
|
||||
/// Returns a new instance of database.
|
||||
///
|
||||
/// Generally used with [ConnectionMode.regular].
|
||||
static dynamic constructDatabase(
|
||||
static Future<DelegatedDatabase> constructDatabase(
|
||||
String userId, {
|
||||
bool logStatements = false,
|
||||
bool persistOnDisk = true,
|
||||
@@ -16,7 +18,7 @@ class SharedDB {
|
||||
/// Return a new instance of moor chat database.
|
||||
///
|
||||
/// Generally used with [ConnectionMode.background].
|
||||
static dynamic constructMoorChatDatabase(
|
||||
static MoorChatDatabase constructMoorChatDatabase(
|
||||
String userId, {
|
||||
bool logStatements = false,
|
||||
}) {
|
||||
|
||||
@@ -22,10 +22,10 @@ class SharedDB {
|
||||
/// default constructor.
|
||||
///
|
||||
/// Generally used with [ConnectionMode.background].
|
||||
static Future<MoorChatDatabase> constructMoorChatDatabase(
|
||||
static MoorChatDatabase constructMoorChatDatabase(
|
||||
String userId, {
|
||||
bool logStatements = false,
|
||||
}) async {
|
||||
}) {
|
||||
final dbName = 'db_$userId';
|
||||
return MoorChatDatabase(dbName, logStatements: logStatements);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user