fix: use TryGet.optional

This commit is contained in:
Lukas Lihotzki 2021-07-23 13:31:55 +02:00
parent 6d6830505f
commit 46b2f8898e
2 changed files with 10 additions and 8 deletions

View File

@ -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<int>('signed_curve25519') ?? 0;
final keyCount =
countJson?.tryGet<int>('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.

View File

@ -778,10 +778,11 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
: null;
// calculate the status
final newStatus = eventUpdate.content.tryGet<int>('status') ??
final newStatus =
eventUpdate.content.tryGet<int>('status', TryGet.optional) ??
eventUpdate.content
.tryGetMap<String, dynamic>('unsigned')
?.tryGet<int>(messageSendingStatusKey) ??
.tryGetMap<String, dynamic>('unsigned', TryGet.optional)
?.tryGet<int>(messageSendingStatusKey, TryGet.optional) ??
2;
final status = newStatus == -1 || prevEvent?.status == null
@ -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<String, dynamic>('unsigned')
?.tryGet<String>('transaction_id');
.tryGetMap<String, dynamic>('unsigned', TryGet.optional)
?.tryGet<String>('transaction_id', TryGet.optional);
await _eventsBox.put(MultiKey(eventUpdate.roomID, eventId).toString(),
eventUpdate.content);