From 46b2f8898e927de681746a6a1cbb42641c75549f Mon Sep 17 00:00:00 2001 From: Lukas Lihotzki Date: Fri, 23 Jul 2021 13:31:55 +0200 Subject: [PATCH] fix: use TryGet.optional --- lib/encryption/olm_manager.dart | 3 ++- lib/src/database/hive_database.dart | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/encryption/olm_manager.dart b/lib/encryption/olm_manager.dart index 47f8ed48..75071e3c 100644 --- a/lib/encryption/olm_manager.dart +++ b/lib/encryption/olm_manager.dart @@ -264,7 +264,8 @@ class OlmManager { // and generate and upload more if not. // If the server did not send us a count, assume it is 0 - final keyCount = countJson?.tryGet('signed_curve25519') ?? 0; + final keyCount = + countJson?.tryGet('signed_curve25519', TryGet.optional) ?? 0; // If the server does not support fallback keys, it will not tell us about them. // If the server supports them but has no key, upload a new one. diff --git a/lib/src/database/hive_database.dart b/lib/src/database/hive_database.dart index d0832e2e..2d1ff83a 100644 --- a/lib/src/database/hive_database.dart +++ b/lib/src/database/hive_database.dart @@ -778,11 +778,12 @@ class FamedlySdkHiveDatabase extends DatabaseApi { : null; // calculate the status - final newStatus = eventUpdate.content.tryGet('status') ?? - eventUpdate.content - .tryGetMap('unsigned') - ?.tryGet(messageSendingStatusKey) ?? - 2; + final newStatus = + eventUpdate.content.tryGet('status', TryGet.optional) ?? + eventUpdate.content + .tryGetMap('unsigned', TryGet.optional) + ?.tryGet(messageSendingStatusKey, TryGet.optional) ?? + 2; final status = newStatus == -1 || prevEvent?.status == null ? newStatus @@ -796,8 +797,8 @@ class FamedlySdkHiveDatabase extends DatabaseApi { // In case this event has sent from this account we have a transaction ID final transactionId = eventUpdate.content - .tryGetMap('unsigned') - ?.tryGet('transaction_id'); + .tryGetMap('unsigned', TryGet.optional) + ?.tryGet('transaction_id', TryGet.optional); await _eventsBox.put(MultiKey(eventUpdate.roomID, eventId).toString(), eventUpdate.content);