Skip to content

Commit

Permalink
fix(notification): remove listener on auth changes
Browse files Browse the repository at this point in the history
  • Loading branch information
realth000 committed Dec 25, 2024
1 parent 16918d6 commit 1428caf
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions lib/features/notification/bloc/auto_notification_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -37,24 +36,12 @@ final class AutoNotificationCubit extends Cubit<AutoNoticeState>
}) : _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<AuthStatus> _authSub;

/// Duration between auto fetch actions.
Duration duration;

Expand Down Expand Up @@ -179,7 +166,6 @@ final class AutoNotificationCubit extends Cubit<AutoNoticeState>
@override
Future<void> close() async {
_timer?.cancel();
await _authSub.cancel();
await super.close();
}
}

0 comments on commit 1428caf

Please sign in to comment.