mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-23 09:16:54 +00:00
Fix ServerDetailsCubit exception
This commit is contained in:
parent
a7248a9b30
commit
e3d7f2b3d7
|
@ -32,6 +32,7 @@ class BlocAndProviderConfig extends StatelessWidget {
|
|||
final apiVolumesCubit = ApiProviderVolumeCubit(serverInstallationCubit);
|
||||
final apiServerVolumesCubit = ApiServerVolumeCubit(serverInstallationCubit);
|
||||
final serverJobsCubit = ServerJobsCubit(serverInstallationCubit);
|
||||
final serverDetailsCubit = ServerDetailsCubit(serverInstallationCubit);
|
||||
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
|
@ -78,6 +79,9 @@ class BlocAndProviderConfig extends StatelessWidget {
|
|||
BlocProvider(
|
||||
create: (final _) => serverJobsCubit..load(),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (final _) => serverDetailsCubit..load(),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (final _) => JobsCubit(
|
||||
usersCubit: usersCubit,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:selfprivacy/config/get_it_config.dart';
|
||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/server_detailed_info/server_detailed_info_repository.dart';
|
||||
import 'package:selfprivacy/logic/models/auto_upgrade_settings.dart';
|
||||
import 'package:selfprivacy/logic/models/json/hetzner_server_info.dart';
|
||||
|
@ -8,8 +7,10 @@ import 'package:selfprivacy/logic/models/timezone_settings.dart';
|
|||
|
||||
part 'server_detailed_info_state.dart';
|
||||
|
||||
class ServerDetailsCubit extends Cubit<ServerDetailsState> {
|
||||
ServerDetailsCubit() : super(ServerDetailsInitial());
|
||||
class ServerDetailsCubit
|
||||
extends ServerInstallationDependendCubit<ServerDetailsState> {
|
||||
ServerDetailsCubit(final ServerInstallationCubit serverInstallationCubit)
|
||||
: super(serverInstallationCubit, ServerDetailsInitial());
|
||||
|
||||
ServerDetailsRepository repository = ServerDetailsRepository();
|
||||
|
||||
|
@ -34,4 +35,29 @@ class ServerDetailsCubit extends Cubit<ServerDetailsState> {
|
|||
print('Tried to emit server info state when cubit is closed');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setTimezone(
|
||||
final String timezone,
|
||||
) async {
|
||||
final ServerDetailsRepositoryDto data = await repository.load();
|
||||
await repository.setTimezone(timezone);
|
||||
emit(
|
||||
Loaded(
|
||||
serverInfo: data.hetznerServerInfo,
|
||||
autoUpgradeSettings: data.autoUpgradeSettings,
|
||||
serverTimezone: TimeZoneSettings.fromString(timezone),
|
||||
checkTime: DateTime.now(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void clear() {
|
||||
emit(ServerDetailsNotReady());
|
||||
}
|
||||
|
||||
@override
|
||||
void load() async {
|
||||
check();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
part of 'server_detailed_info_cubit.dart';
|
||||
|
||||
abstract class ServerDetailsState extends Equatable {
|
||||
abstract class ServerDetailsState extends ServerInstallationDependendState {
|
||||
const ServerDetailsState();
|
||||
|
||||
@override
|
||||
|
|
|
@ -76,7 +76,7 @@ class _ServerDetailsScreenState extends State<ServerDetailsScreen>
|
|||
}
|
||||
|
||||
return BlocProvider(
|
||||
create: (final context) => ServerDetailsCubit()..check(),
|
||||
create: (final context) => context.read<ServerDetailsCubit>()..check(),
|
||||
child: BrandHeroScreen(
|
||||
heroIcon: BrandIcons.server,
|
||||
heroTitle: 'providers.server.card_title'.tr(),
|
||||
|
|
Loading…
Reference in a new issue