2022-07-12 15:54:16 +03:00
|
|
|
import 'package:selfprivacy/logic/api_maps/rest_maps/server.dart';
|
2021-08-29 16:54:28 +03:00
|
|
|
import 'package:selfprivacy/logic/common_enum/common_enum.dart';
|
2021-09-29 16:08:19 +03:00
|
|
|
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
2021-08-29 12:50:24 +03:00
|
|
|
|
|
|
|
part 'services_state.dart';
|
|
|
|
|
2022-05-17 16:31:34 +03:00
|
|
|
class ServicesCubit extends ServerInstallationDependendCubit<ServicesState> {
|
2022-06-05 22:36:32 +03:00
|
|
|
ServicesCubit(final ServerInstallationCubit serverInstallationCubit)
|
2022-05-17 23:08:28 +03:00
|
|
|
: super(serverInstallationCubit, ServicesState.allOff());
|
2022-06-05 22:36:32 +03:00
|
|
|
final ServerApi api = ServerApi();
|
2022-05-24 21:55:39 +03:00
|
|
|
@override
|
2021-09-29 16:08:19 +03:00
|
|
|
Future<void> load() async {
|
2022-05-17 23:08:28 +03:00
|
|
|
if (serverInstallationCubit.state is ServerInstallationFinished) {
|
2022-06-05 22:36:32 +03:00
|
|
|
final Map<ServiceTypes, bool> statuses = await api.servicesPowerCheck();
|
2021-09-29 21:28:47 +03:00
|
|
|
emit(
|
|
|
|
ServicesState(
|
|
|
|
isPasswordManagerEnable: statuses[ServiceTypes.passwordManager]!,
|
|
|
|
isCloudEnable: statuses[ServiceTypes.cloud]!,
|
|
|
|
isGitEnable: statuses[ServiceTypes.git]!,
|
|
|
|
isSocialNetworkEnable: statuses[ServiceTypes.socialNetwork]!,
|
|
|
|
isVpnEnable: statuses[ServiceTypes.vpn]!,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2021-08-29 16:54:28 +03:00
|
|
|
}
|
|
|
|
|
2021-09-29 16:08:19 +03:00
|
|
|
@override
|
|
|
|
void clear() async {
|
2021-08-29 16:54:28 +03:00
|
|
|
emit(ServicesState.allOff());
|
|
|
|
}
|
2021-08-29 12:50:24 +03:00
|
|
|
}
|