[StreamChatPersistence] Fix ownReactions userId bug

Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
Sahil Kumar
2021-01-27 15:51:55 +05:30
parent e74a0d40ff
commit 3b9af05214
9 changed files with 29 additions and 19 deletions
@@ -12,9 +12,10 @@ import '../moor_chat_database.dart';
class SharedDB {
static Future<VmDatabase> constructDatabase(
String dbName, {
String userId, {
bool logStatements = false,
}) async {
final dbName = 'db_$userId';
if (Platform.isIOS || Platform.isAndroid) {
final dir = await getApplicationDocumentsDirectory();
final path = join(dir.path, '$dbName.sqlite');
@@ -62,15 +63,16 @@ class SharedDB {
}
static Future<MoorChatDatabase> constructOfflineStorage(
String dbName, {
String userId, {
bool logStatements = false,
}) async {
final dbName = 'db_$userId';
final isolate = await _createMoorIsolate(
dbName,
logStatements: logStatements,
);
final connection = await isolate.connect();
return MoorChatDatabase.connect(isolate, connection);
return MoorChatDatabase.connect(userId, isolate, connection);
}
}
@@ -3,14 +3,14 @@
class SharedDB {
static constructDatabase(
String dbName, {
String userId, {
bool logStatements = false,
}) {
throw 'Unsupported Platform';
}
static constructOfflineStorage(
String dbName, {
String userId, {
bool logStatements = false,
}) {
throw 'Unsupported Platform';
@@ -6,16 +6,18 @@ import '../moor_chat_database.dart';
class SharedDB {
static constructDatabase(
String dbName, {
String userId, {
bool logStatements = false,
}) async {
final dbName = 'db_$userId';
return WebDatabase(dbName, logStatements: logStatements);
}
static Future<MoorChatDatabase> constructOfflineStorage(
String dbName, {
String userId, {
bool logStatements = false,
}) async {
final dbName = 'db_$userId';
return MoorChatDatabase(dbName, logStatements: logStatements);
}
}