diff --git a/lib/src/database/database_api.dart b/lib/src/database/database_api.dart index 797ab55a..669b18be 100644 --- a/lib/src/database/database_api.dart +++ b/lib/src/database/database_api.dart @@ -22,7 +22,7 @@ import 'package:matrix/encryption/utils/olm_session.dart'; import 'package:matrix/encryption/utils/outbound_group_session.dart'; import 'package:matrix/encryption/utils/ssss_cache.dart'; import 'package:matrix/encryption/utils/stored_inbound_group_session.dart'; -import 'package:matrix/src/utils/QueuedToDeviceEvent.dart'; +import 'package:matrix/src/utils/queued_to_device_event.dart'; import '../../matrix.dart'; @@ -80,7 +80,7 @@ abstract class DatabaseApi { Future> getEventList(int clientId, Room room); - Future getFile(String mxcUri); + Future getFile(Uri mxcUri); Future storeFile(Uri mxcUri, Uint8List bytes, int time); diff --git a/lib/src/database/hive_database.dart b/lib/src/database/hive_database.dart index 05f7466e..f9696a21 100644 --- a/lib/src/database/hive_database.dart +++ b/lib/src/database/hive_database.dart @@ -328,7 +328,7 @@ class FamedlySdkHiveDatabase extends DatabaseApi { } @override - Future getFile(String mxcUri) async { + Future getFile(Uri mxcUri) async { return null; } diff --git a/lib/src/utils/uia_request.dart b/lib/src/utils/uia_request.dart index 575b56e0..65511d0f 100644 --- a/lib/src/utils/uia_request.dart +++ b/lib/src/utils/uia_request.dart @@ -1,4 +1,3 @@ -// @dart=2.9 /* * Famedly Matrix SDK * Copyright (C) 2020, 2021 Famedly GmbH @@ -35,12 +34,12 @@ enum UiaRequestState { /// Wrapper to handle User interactive authentication requests class UiaRequest { - void Function(UiaRequestState state) onUpdate; - final Future Function(AuthenticationData auth) request; - String session; + void Function(UiaRequestState state)? onUpdate; + final Future Function(AuthenticationData? auth) request; + String? session; UiaRequestState _state = UiaRequestState.loading; - T result; - Exception error; + T? result; + Exception? error; Set nextStages = {}; Map params = {}; @@ -52,11 +51,11 @@ class UiaRequest { onUpdate?.call(newState); } - UiaRequest({this.onUpdate, this.request}) { + UiaRequest({this.onUpdate, required this.request}) { _run(); } - Future _run([AuthenticationData auth]) async { + Future _run([AuthenticationData? auth]) async { state = UiaRequestState.loading; try { final res = await request(auth); @@ -68,7 +67,7 @@ class UiaRequest { rethrow; } session ??= err.session; - final completed = err.completedAuthenticationFlows ?? []; + final completed = err.completedAuthenticationFlows; final flows = err.authenticationFlows ?? []; params = err.authenticationParams ?? {}; nextStages = getNextStages(flows, completed); @@ -87,10 +86,10 @@ class UiaRequest { } } - Future completeStage(AuthenticationData auth) => _run(auth); + Future completeStage(AuthenticationData auth) => _run(auth); /// Cancel this uia request for example if the app can not handle this stage. - void cancel([Exception err]) { + void cancel([Exception? err]) { error = err ?? Exception('Request has been canceled'); state = UiaRequestState.fail; } @@ -101,18 +100,16 @@ class UiaRequest { for (final flow in flows) { final stages = flow.stages; final nextStage = stages[completed.length]; - if (nextStage != null) { - var stagesValid = true; - for (var i = 0; i < completed.length; i++) { - if (stages[i] != completed[i]) { - stagesValid = false; - break; - } - } - if (stagesValid) { - nextStages.add(nextStage); + var stagesValid = true; + for (var i = 0; i < completed.length; i++) { + if (stages[i] != completed[i]) { + stagesValid = false; + break; } } + if (stagesValid) { + nextStages.add(nextStage); + } } return nextStages; }