mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-11 18:39:45 +00:00
Implement initialization migration to binds error handling
This commit is contained in:
parent
cb660eb2bb
commit
159f861965
|
@ -1,5 +1,15 @@
|
||||||
part of 'server.dart';
|
part of 'server.dart';
|
||||||
|
|
||||||
|
class MigrateToBindsMutationReturn extends GenericMutationResult {
|
||||||
|
MigrateToBindsMutationReturn({
|
||||||
|
required final super.success,
|
||||||
|
required final super.code,
|
||||||
|
final super.message,
|
||||||
|
this.jobUid,
|
||||||
|
});
|
||||||
|
final String? jobUid;
|
||||||
|
}
|
||||||
|
|
||||||
mixin VolumeApi on ApiMap {
|
mixin VolumeApi on ApiMap {
|
||||||
Future<List<ServerDiskVolume>> getServerDiskVolumes() async {
|
Future<List<ServerDiskVolume>> getServerDiskVolumes() async {
|
||||||
QueryResult response;
|
QueryResult response;
|
||||||
|
@ -57,10 +67,11 @@ mixin VolumeApi on ApiMap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> migrateToBinds(
|
Future<MigrateToBindsMutationReturn> migrateToBinds(
|
||||||
final Map<String, String> serviceToDisk,
|
final Map<String, String> serviceToDisk,
|
||||||
) async {
|
) async {
|
||||||
String? jobUid;
|
MigrateToBindsMutationReturn? mutation;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final GraphQLClient client = await getClient();
|
final GraphQLClient client = await getClient();
|
||||||
final input = Input$MigrateToBindsInput(
|
final input = Input$MigrateToBindsInput(
|
||||||
|
@ -77,12 +88,22 @@ mixin VolumeApi on ApiMap {
|
||||||
await client.mutate$MigrateToBinds(
|
await client.mutate$MigrateToBinds(
|
||||||
migrateMutation,
|
migrateMutation,
|
||||||
);
|
);
|
||||||
|
mutation = mutation = MigrateToBindsMutationReturn(
|
||||||
jobUid = result.parsedData!.migrateToBinds.job!.uid;
|
success: result.parsedData!.migrateToBinds.success,
|
||||||
|
code: result.parsedData!.migrateToBinds.code,
|
||||||
|
message: result.parsedData!.migrateToBinds.message,
|
||||||
|
jobUid: result.parsedData!.migrateToBinds.job?.uid,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
|
mutation = MigrateToBindsMutationReturn(
|
||||||
|
success: false,
|
||||||
|
code: 0,
|
||||||
|
message: e.toString(),
|
||||||
|
jobUid: null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return jobUid;
|
return mutation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:selfprivacy/config/get_it_config.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/server_job.dart';
|
import 'package:selfprivacy/logic/models/json/server_job.dart';
|
||||||
|
@ -44,10 +45,15 @@ class ServerJobsCubit
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> migrateToBinds(final Map<String, String> serviceToDisk) async {
|
Future<void> migrateToBinds(final Map<String, String> serviceToDisk) async {
|
||||||
final String? jobUid = await api.migrateToBinds(serviceToDisk);
|
final result = await api.migrateToBinds(serviceToDisk);
|
||||||
|
if (!result.success || result.jobUid == null) {
|
||||||
|
getIt<NavigationService>().showSnackBar(result.message!);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
emit(
|
emit(
|
||||||
ServerJobsState(
|
ServerJobsState(
|
||||||
migrationJobUid: jobUid,
|
migrationJobUid: result.jobUid,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue