mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-08-25 06:21:52 +00:00
41 lines
1.1 KiB
Dart
41 lines
1.1 KiB
Dart
import 'dart:async';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:equatable/equatable.dart';
|
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
|
|
|
export 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
|
|
|
part 'authentication_dependend_state.dart';
|
|
|
|
abstract class ServerInstallationDependendCubit<
|
|
T extends ServerInstallationDependendState> extends Cubit<T> {
|
|
ServerInstallationDependendCubit(
|
|
this.serverInstallationCubit,
|
|
final T initState,
|
|
) : super(initState) {
|
|
authCubitSubscription =
|
|
serverInstallationCubit.stream.listen(checkAuthStatus);
|
|
checkAuthStatus(serverInstallationCubit.state);
|
|
}
|
|
|
|
void checkAuthStatus(final ServerInstallationState state) {
|
|
if (state is ServerInstallationFinished) {
|
|
load();
|
|
} else if (state is ServerInstallationEmpty) {
|
|
clear();
|
|
}
|
|
}
|
|
|
|
late StreamSubscription authCubitSubscription;
|
|
final ServerInstallationCubit serverInstallationCubit;
|
|
|
|
void load();
|
|
void clear();
|
|
|
|
@override
|
|
Future<void> close() {
|
|
authCubitSubscription.cancel();
|
|
return super.close();
|
|
}
|
|
}
|