From f038218cf411222aa1a1a5a2e4f17c8a038ef3b4 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 14 Jun 2019 11:04:57 +0000 Subject: [PATCH 1/5] Add some logs to direct chat storing --- lib/src/Store.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/src/Store.dart b/lib/src/Store.dart index d05dd0aa..e3fc5736 100644 --- a/lib/src/Store.dart +++ b/lib/src/Store.dart @@ -184,12 +184,16 @@ class Store { case "m.direct": if (userUpdate.content["content"] is Map) { final Map directMap = userUpdate.content["content"]; + print("Direct Map =========> $directMap"); directMap.forEach((String key, dynamic value) { + print("Handle direct Matrix ID ===========> $key"); if (value is List && value.length > 0) - for (int i = 0; i < value.length; i++) - txn.rawUpdate( + for (int i = 0; i < value.length; i++) { + final changesCount = await txn.rawUpdate( "UPDATE Rooms SET direct_chat_matrix_id=? WHERE id=?", [key, value[i]]); + if (changesCount == 0) print("Direct chat of $key, was not stored"); + } }); } break; From d108f1f7e6d8d76bf6986b8af64f52e69922fbd6 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 14 Jun 2019 11:06:25 +0000 Subject: [PATCH 2/5] Update lib/src/Store.dart --- lib/src/Store.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/Store.dart b/lib/src/Store.dart index e3fc5736..1c57ddb9 100644 --- a/lib/src/Store.dart +++ b/lib/src/Store.dart @@ -185,7 +185,7 @@ class Store { if (userUpdate.content["content"] is Map) { final Map directMap = userUpdate.content["content"]; print("Direct Map =========> $directMap"); - directMap.forEach((String key, dynamic value) { + directMap.forEach((String key, dynamic value) async{ print("Handle direct Matrix ID ===========> $key"); if (value is List && value.length > 0) for (int i = 0; i < value.length; i++) { From 6101a2251acf2261c20380a2d8e88cdb931183b4 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 14 Jun 2019 11:11:53 +0000 Subject: [PATCH 3/5] Update lib/src/Store.dart --- lib/src/Store.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/Store.dart b/lib/src/Store.dart index 1c57ddb9..f8382291 100644 --- a/lib/src/Store.dart +++ b/lib/src/Store.dart @@ -192,7 +192,7 @@ class Store { final changesCount = await txn.rawUpdate( "UPDATE Rooms SET direct_chat_matrix_id=? WHERE id=?", [key, value[i]]); - if (changesCount == 0) print("Direct chat of $key, was not stored"); + if (changesCount == 0) print("Direct chat of $key to Room ${value[i]}, was not stored"); } }); } From cf60b509541db878a71a1a090769d0d8c65d4424 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 14 Jun 2019 11:17:28 +0000 Subject: [PATCH 4/5] Update lib/src/Store.dart --- lib/src/Store.dart | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/src/Store.dart b/lib/src/Store.dart index f8382291..13f244a1 100644 --- a/lib/src/Store.dart +++ b/lib/src/Store.dart @@ -184,15 +184,12 @@ class Store { case "m.direct": if (userUpdate.content["content"] is Map) { final Map directMap = userUpdate.content["content"]; - print("Direct Map =========> $directMap"); - directMap.forEach((String key, dynamic value) async{ - print("Handle direct Matrix ID ===========> $key"); + directMap.forEach((String key, dynamic value) { if (value is List && value.length > 0) for (int i = 0; i < value.length; i++) { - final changesCount = await txn.rawUpdate( + txn.rawUpdate( "UPDATE Rooms SET direct_chat_matrix_id=? WHERE id=?", [key, value[i]]); - if (changesCount == 0) print("Direct chat of $key to Room ${value[i]}, was not stored"); } }); } From 167a7155f8f1ac7df11e368dbe5301d04b5fd05f Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 15 Jun 2019 07:16:45 +0000 Subject: [PATCH 5/5] Update lib/src/Room.dart --- lib/src/Room.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/Room.dart b/lib/src/Room.dart index 9a8b373e..0949d75a 100644 --- a/lib/src/Room.dart +++ b/lib/src/Room.dart @@ -130,7 +130,7 @@ class Room { /// The last message sent to this room. String get lastMessage { - if (events?.length > 0) + if (events != null && events.length > 0) return events[0].getBody(); else return "";