6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 1159c342

AuthorNKL<nikolaj.king@gmail.com>
Date2024-10-14 13:21:58 +0200
cleaned a bit

Changed files

comwell_key_app/lib/authentication/authentication_repository.dart | 1 -
 comwell_key_app/lib/authentication/bloc/authentication_bloc.dart  | 6 +++++-
 comwell_key_app/lib/authentication/bloc/authentication_event.dart | 2 ++
 comwell_key_app/lib/login/components/azure_b2c_widget.dart        | 2 +-
 comwell_key_app/lib/routing/app_router.dart                       | 1 -
 comwell_key_app/lib/utils/stream_to_listenable.dart               | 4 ++--
 6 files changed, 10 insertions(+), 6 deletions(-)

Diff

diff --git a/comwell_key_app/lib/authentication/authentication_repository.dart b/comwell_key_app/lib/authentication/authentication_repository.dart
index 4c2137a7..f0971c87 100644
--- a/comwell_key_app/lib/authentication/authentication_repository.dart
+++ b/comwell_key_app/lib/authentication/authentication_repository.dart
@@ -11,7 +11,6 @@ class AuthenticationRepository {
await Future<void>.delayed(const Duration(seconds: 1));
//yield AuthenticationStatus.unauthenticated;
yield* _controller.stream;
- print("Stream: ${_controller.stream}");
}
Future<void> logIn() async {
diff --git a/comwell_key_app/lib/authentication/bloc/authentication_bloc.dart b/comwell_key_app/lib/authentication/bloc/authentication_bloc.dart
index 7aa0997b..78286c5d 100644
--- a/comwell_key_app/lib/authentication/bloc/authentication_bloc.dart
+++ b/comwell_key_app/lib/authentication/bloc/authentication_bloc.dart
@@ -15,6 +15,7 @@ class AuthenticationBloc
on<AuthenticationSubscriptionRequested>(_onSubscriptionRequested);
on<AuthenticationLogoutPressed>(_onLogoutPressed);
on<AuthenticationLoginPressed>(_onLoginPressed);
+ on<AuthenticationRequestFailed>(_loginErrorFromAzureB2C);
}
final AuthenticationRepository _authenticationRepository;
@@ -58,7 +59,10 @@ class AuthenticationBloc
}
}
- void loginErrorFromAzureB2C() {
+ void _loginErrorFromAzureB2C(
+ AuthenticationRequestFailed event,
+ Emitter<AuthenticationState> emit,
+ ) {
emit(const AuthenticationState.unauthenticated());
_authenticationRepository.logOut();
}
diff --git a/comwell_key_app/lib/authentication/bloc/authentication_event.dart b/comwell_key_app/lib/authentication/bloc/authentication_event.dart
index 09363031..b44a83e1 100644
--- a/comwell_key_app/lib/authentication/bloc/authentication_event.dart
+++ b/comwell_key_app/lib/authentication/bloc/authentication_event.dart
@@ -15,3 +15,5 @@ final class AuthenticationLogoutPressed extends AuthenticationEvent {}
final class AuthenticationLoginPressed extends AuthenticationEvent {}
+final class AuthenticationRequestFailed extends AuthenticationEvent {}
+
diff --git a/comwell_key_app/lib/login/components/azure_b2c_widget.dart b/comwell_key_app/lib/login/components/azure_b2c_widget.dart
index 540f9104..675277bc 100644
--- a/comwell_key_app/lib/login/components/azure_b2c_widget.dart
+++ b/comwell_key_app/lib/login/components/azure_b2c_widget.dart
@@ -41,7 +41,7 @@ class AzureB2CWidget extends StatelessWidget {
secureStorage.write('refresh_token', token.value);
authBloc.add(AuthenticationLoginPressed());
},
- onErrorOrCancel: (context) => authBloc.loginErrorFromAzureB2C(),
+ onErrorOrCancel: (context) => authBloc.add(AuthenticationRequestFailed()),
optionalParameters: const [],
webViewBackgroundColor: sandColor[40]!,
);
diff --git a/comwell_key_app/lib/routing/app_router.dart b/comwell_key_app/lib/routing/app_router.dart
index 4a1ad377..fcc65439 100644
--- a/comwell_key_app/lib/routing/app_router.dart
+++ b/comwell_key_app/lib/routing/app_router.dart
@@ -1,6 +1,5 @@
import 'package:comwell_key_app/authentication/authentication_repository.dart';
import 'package:comwell_key_app/authentication/bloc/authentication_bloc.dart';
-import 'package:comwell_key_app/authentication/enum/authentication_status.dart';
import 'package:comwell_key_app/home/home_page.dart';
import 'package:comwell_key_app/key/key_page.dart';
import 'package:comwell_key_app/login/login_page.dart';
diff --git a/comwell_key_app/lib/utils/stream_to_listenable.dart b/comwell_key_app/lib/utils/stream_to_listenable.dart
index b2c1c56e..35de3b66 100644
--- a/comwell_key_app/lib/utils/stream_to_listenable.dart
+++ b/comwell_key_app/lib/utils/stream_to_listenable.dart
@@ -4,9 +4,9 @@ import 'dart:async';
import 'package:flutter/widgets.dart';
class StreamToListenable extends ChangeNotifier {
- late final List<StreamSubscription> subscriptions;
+ late final List<StreamSubscription<dynamic>> subscriptions;
- StreamToListenable(List<Stream> streams) {
+ StreamToListenable(List<Stream<dynamic>> streams) {
subscriptions = [];
for (var e in streams) {
var s = e.asBroadcastStream().listen(_tt);