mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-09-07 04:26:56 +00:00
3e7d003f21
Co-authored-by: Kherel <kherel@gmail.com> Reviewed-on: https://git.selfprivacy.org/kherel/selfprivacy.org.app/pulls/65 Co-authored-by: kherel <kherel@gmail.com> Co-committed-by: kherel <kherel@gmail.com>
40 lines
1,001 B
Dart
40 lines
1,001 B
Dart
import 'dart:async';
|
|
import 'package:bloc/bloc.dart';
|
|
import 'package:equatable/equatable.dart';
|
|
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
|
|
|
export 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
|
|
|
part 'authentication_dependend_state.dart';
|
|
|
|
abstract class AppConfigDependendCubit<T extends AppConfigDependendState>
|
|
extends Cubit<T> {
|
|
AppConfigDependendCubit(
|
|
this.appConfigCubit,
|
|
T initState,
|
|
) : super(initState) {
|
|
authCubitSubscription = appConfigCubit.stream.listen(checkAuthStatus);
|
|
checkAuthStatus(appConfigCubit.state);
|
|
}
|
|
|
|
void checkAuthStatus(AppConfigState state) {
|
|
if (state is AppConfigFinished) {
|
|
load();
|
|
} else if (state is AppConfigEmpty) {
|
|
clear();
|
|
}
|
|
}
|
|
|
|
late StreamSubscription authCubitSubscription;
|
|
final AppConfigCubit appConfigCubit;
|
|
|
|
void load();
|
|
void clear();
|
|
|
|
@override
|
|
Future<void> close() {
|
|
authCubitSubscription.cancel();
|
|
return super.close();
|
|
}
|
|
}
|