mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-08-25 22:41:51 +00:00
Removing Hetzner type hardcode from server page and replacing it with generic String-based metadata container
49 lines
1.5 KiB
Dart
49 lines
1.5 KiB
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/server_metadata.dart';
|
|
import 'package:selfprivacy/logic/models/timezone_settings.dart';
|
|
|
|
part 'server_detailed_info_state.dart';
|
|
|
|
class ServerDetailsCubit
|
|
extends ServerInstallationDependendCubit<ServerDetailsState> {
|
|
ServerDetailsCubit(final ServerInstallationCubit serverInstallationCubit)
|
|
: super(serverInstallationCubit, ServerDetailsInitial());
|
|
|
|
ServerDetailsRepository repository = ServerDetailsRepository();
|
|
|
|
void check() async {
|
|
final bool isReadyToCheck = getIt<ApiConfigModel>().serverDetails != null;
|
|
try {
|
|
if (isReadyToCheck) {
|
|
emit(ServerDetailsLoading());
|
|
final ServerDetailsRepositoryDto data = await repository.load();
|
|
emit(
|
|
Loaded(
|
|
metadata: data.metadata,
|
|
autoUpgradeSettings: data.autoUpgradeSettings,
|
|
serverTimezone: data.serverTimezone,
|
|
checkTime: DateTime.now(),
|
|
),
|
|
);
|
|
} else {
|
|
emit(ServerDetailsNotReady());
|
|
}
|
|
} on StateError {
|
|
print('Tried to emit server info state when cubit is closed');
|
|
}
|
|
}
|
|
|
|
@override
|
|
void clear() {
|
|
emit(ServerDetailsNotReady());
|
|
}
|
|
|
|
@override
|
|
void load() async {
|
|
check();
|
|
}
|
|
}
|