From 1428caf7b0be1e38e237b7e2985d677578628b00 Mon Sep 17 00:00:00 2001 From: realth000 Date: Thu, 26 Dec 2024 05:38:55 +0800 Subject: [PATCH] fix(notification): remove listener on auth changes --- .../bloc/auto_notification_cubit.dart | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/lib/features/notification/bloc/auto_notification_cubit.dart b/lib/features/notification/bloc/auto_notification_cubit.dart index 9ece06e1..4f7c5c5b 100644 --- a/lib/features/notification/bloc/auto_notification_cubit.dart +++ b/lib/features/notification/bloc/auto_notification_cubit.dart @@ -6,7 +6,6 @@ import 'package:tsdm_client/exceptions/exceptions.dart'; import 'package:tsdm_client/extensions/date_time.dart'; import 'package:tsdm_client/extensions/fp.dart'; import 'package:tsdm_client/features/authentication/repository/authentication_repository.dart'; -import 'package:tsdm_client/features/authentication/repository/models/models.dart'; import 'package:tsdm_client/features/notification/repository/notification_repository.dart'; import 'package:tsdm_client/shared/providers/storage_provider/storage_provider.dart'; import 'package:tsdm_client/utils/logger.dart'; @@ -37,24 +36,12 @@ final class AutoNotificationCubit extends Cubit }) : _authenticationRepository = authenticationRepository, _notificationRepository = notificationRepository, _storageProvider = storageProvider, - super(const AutoNoticeStateStopped()) { - _authSub = _authenticationRepository.status.listen( - (e) => switch (e) { - AuthStatusUnknown() || - AuthStatusLoading() || - AuthStatusNotAuthed() => - stop(), - AuthStatusAuthed() => start(null), - }, - ); - } + super(const AutoNoticeStateStopped()); final AuthenticationRepository _authenticationRepository; final NotificationRepository _notificationRepository; final StorageProvider _storageProvider; - late final StreamSubscription _authSub; - /// Duration between auto fetch actions. Duration duration; @@ -179,7 +166,6 @@ final class AutoNotificationCubit extends Cubit @override Future close() async { _timer?.cancel(); - await _authSub.cancel(); await super.close(); } }