From 80b83980ce278536e32db989a886efdeb2bd1ee0 Mon Sep 17 00:00:00 2001 From: NaiJi Date: Mon, 7 Aug 2023 09:44:26 -0300 Subject: [PATCH] feat(backup): Implement forget snapshot method --- assets/translations/en.json | 3 +- assets/translations/ru.json | 3 +- .../graphql_maps/schema/backups.graphql | 8 + .../graphql_maps/schema/backups.graphql.dart | 699 ++++++++++++++++++ .../graphql_maps/server_api/backups_api.dart | 38 + lib/logic/cubit/backups/backups_cubit.dart | 14 + 6 files changed, 763 insertions(+), 2 deletions(-) diff --git a/assets/translations/en.json b/assets/translations/en.json index 51c47263..a5f2d6e2 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -204,7 +204,8 @@ "backups_encryption_key_show": "Show the encryption key", "backups_encryption_key_description": "This key is used to encrypt your backups. If you lose it, you will not be able to restore your backups. Keep it in a safe place, as it will be useful if you ever need to restore from backups manually.", "pending_jobs": "Currently running backup jobs", - "snapshots_title": "Snapshot list" + "snapshots_title": "Snapshot list", + "forget_snapshot_error": "Couldn't forget snapshot" }, "storage": { "card_title": "Server Storage", diff --git a/assets/translations/ru.json b/assets/translations/ru.json index fdc276cd..6cd1b00a 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -199,7 +199,8 @@ "autobackup_set_period": "Установить период", "autobackup_period_set": "Период установлен", "backups_encryption_key": "Ключ шифрования", - "snapshots_title": "Список снимков" + "snapshots_title": "Список снимков", + "forget_snapshot_error": "Не удалось забыть снимок" }, "storage": { "card_title": "Хранилище", diff --git a/lib/logic/api_maps/graphql_maps/schema/backups.graphql b/lib/logic/api_maps/graphql_maps/schema/backups.graphql index 432678d0..9b60564c 100644 --- a/lib/logic/api_maps/graphql_maps/schema/backups.graphql +++ b/lib/logic/api_maps/graphql_maps/schema/backups.graphql @@ -90,4 +90,12 @@ mutation RestoreBackup($snapshotId: String!, $strategy: RestoreStrategy! = DOWNL } } } +} + +mutation ForgetSnapshot($snapshotId: String!) { + backup { + forgetSnapshot(snapshotId: $snapshotId) { + ...basicMutationReturnFields + } + } } \ No newline at end of file diff --git a/lib/logic/api_maps/graphql_maps/schema/backups.graphql.dart b/lib/logic/api_maps/graphql_maps/schema/backups.graphql.dart index 72399c2c..7a814aac 100644 --- a/lib/logic/api_maps/graphql_maps/schema/backups.graphql.dart +++ b/lib/logic/api_maps/graphql_maps/schema/backups.graphql.dart @@ -5774,3 +5774,702 @@ class _CopyWithStubImpl$Mutation$RestoreBackup$backup$restoreBackup CopyWith$Fragment$basicApiJobsFields get job => CopyWith$Fragment$basicApiJobsFields.stub(_res); } + +class Variables$Mutation$ForgetSnapshot { + factory Variables$Mutation$ForgetSnapshot({required String snapshotId}) => + Variables$Mutation$ForgetSnapshot._({ + r'snapshotId': snapshotId, + }); + + Variables$Mutation$ForgetSnapshot._(this._$data); + + factory Variables$Mutation$ForgetSnapshot.fromJson( + Map data) { + final result$data = {}; + final l$snapshotId = data['snapshotId']; + result$data['snapshotId'] = (l$snapshotId as String); + return Variables$Mutation$ForgetSnapshot._(result$data); + } + + Map _$data; + + String get snapshotId => (_$data['snapshotId'] as String); + Map toJson() { + final result$data = {}; + final l$snapshotId = snapshotId; + result$data['snapshotId'] = l$snapshotId; + return result$data; + } + + CopyWith$Variables$Mutation$ForgetSnapshot + get copyWith => CopyWith$Variables$Mutation$ForgetSnapshot( + this, + (i) => i, + ); + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Variables$Mutation$ForgetSnapshot) || + runtimeType != other.runtimeType) { + return false; + } + final l$snapshotId = snapshotId; + final lOther$snapshotId = other.snapshotId; + if (l$snapshotId != lOther$snapshotId) { + return false; + } + return true; + } + + @override + int get hashCode { + final l$snapshotId = snapshotId; + return Object.hashAll([l$snapshotId]); + } +} + +abstract class CopyWith$Variables$Mutation$ForgetSnapshot { + factory CopyWith$Variables$Mutation$ForgetSnapshot( + Variables$Mutation$ForgetSnapshot instance, + TRes Function(Variables$Mutation$ForgetSnapshot) then, + ) = _CopyWithImpl$Variables$Mutation$ForgetSnapshot; + + factory CopyWith$Variables$Mutation$ForgetSnapshot.stub(TRes res) = + _CopyWithStubImpl$Variables$Mutation$ForgetSnapshot; + + TRes call({String? snapshotId}); +} + +class _CopyWithImpl$Variables$Mutation$ForgetSnapshot + implements CopyWith$Variables$Mutation$ForgetSnapshot { + _CopyWithImpl$Variables$Mutation$ForgetSnapshot( + this._instance, + this._then, + ); + + final Variables$Mutation$ForgetSnapshot _instance; + + final TRes Function(Variables$Mutation$ForgetSnapshot) _then; + + static const _undefined = {}; + + TRes call({Object? snapshotId = _undefined}) => + _then(Variables$Mutation$ForgetSnapshot._({ + ..._instance._$data, + if (snapshotId != _undefined && snapshotId != null) + 'snapshotId': (snapshotId as String), + })); +} + +class _CopyWithStubImpl$Variables$Mutation$ForgetSnapshot + implements CopyWith$Variables$Mutation$ForgetSnapshot { + _CopyWithStubImpl$Variables$Mutation$ForgetSnapshot(this._res); + + TRes _res; + + call({String? snapshotId}) => _res; +} + +class Mutation$ForgetSnapshot { + Mutation$ForgetSnapshot({ + required this.backup, + this.$__typename = 'Mutation', + }); + + factory Mutation$ForgetSnapshot.fromJson(Map json) { + final l$backup = json['backup']; + final l$$__typename = json['__typename']; + return Mutation$ForgetSnapshot( + backup: Mutation$ForgetSnapshot$backup.fromJson( + (l$backup as Map)), + $__typename: (l$$__typename as String), + ); + } + + final Mutation$ForgetSnapshot$backup backup; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$backup = backup; + _resultData['backup'] = l$backup.toJson(); + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$backup = backup; + final l$$__typename = $__typename; + return Object.hashAll([ + l$backup, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Mutation$ForgetSnapshot) || + runtimeType != other.runtimeType) { + return false; + } + final l$backup = backup; + final lOther$backup = other.backup; + if (l$backup != lOther$backup) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Mutation$ForgetSnapshot on Mutation$ForgetSnapshot { + CopyWith$Mutation$ForgetSnapshot get copyWith => + CopyWith$Mutation$ForgetSnapshot( + this, + (i) => i, + ); +} + +abstract class CopyWith$Mutation$ForgetSnapshot { + factory CopyWith$Mutation$ForgetSnapshot( + Mutation$ForgetSnapshot instance, + TRes Function(Mutation$ForgetSnapshot) then, + ) = _CopyWithImpl$Mutation$ForgetSnapshot; + + factory CopyWith$Mutation$ForgetSnapshot.stub(TRes res) = + _CopyWithStubImpl$Mutation$ForgetSnapshot; + + TRes call({ + Mutation$ForgetSnapshot$backup? backup, + String? $__typename, + }); + CopyWith$Mutation$ForgetSnapshot$backup get backup; +} + +class _CopyWithImpl$Mutation$ForgetSnapshot + implements CopyWith$Mutation$ForgetSnapshot { + _CopyWithImpl$Mutation$ForgetSnapshot( + this._instance, + this._then, + ); + + final Mutation$ForgetSnapshot _instance; + + final TRes Function(Mutation$ForgetSnapshot) _then; + + static const _undefined = {}; + + TRes call({ + Object? backup = _undefined, + Object? $__typename = _undefined, + }) => + _then(Mutation$ForgetSnapshot( + backup: backup == _undefined || backup == null + ? _instance.backup + : (backup as Mutation$ForgetSnapshot$backup), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); + CopyWith$Mutation$ForgetSnapshot$backup get backup { + final local$backup = _instance.backup; + return CopyWith$Mutation$ForgetSnapshot$backup( + local$backup, (e) => call(backup: e)); + } +} + +class _CopyWithStubImpl$Mutation$ForgetSnapshot + implements CopyWith$Mutation$ForgetSnapshot { + _CopyWithStubImpl$Mutation$ForgetSnapshot(this._res); + + TRes _res; + + call({ + Mutation$ForgetSnapshot$backup? backup, + String? $__typename, + }) => + _res; + CopyWith$Mutation$ForgetSnapshot$backup get backup => + CopyWith$Mutation$ForgetSnapshot$backup.stub(_res); +} + +const documentNodeMutationForgetSnapshot = DocumentNode(definitions: [ + OperationDefinitionNode( + type: OperationType.mutation, + name: NameNode(value: 'ForgetSnapshot'), + variableDefinitions: [ + VariableDefinitionNode( + variable: VariableNode(name: NameNode(value: 'snapshotId')), + type: NamedTypeNode( + name: NameNode(value: 'String'), + isNonNull: true, + ), + defaultValue: DefaultValueNode(value: null), + directives: [], + ) + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'backup'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'forgetSnapshot'), + alias: null, + arguments: [ + ArgumentNode( + name: NameNode(value: 'snapshotId'), + value: VariableNode(name: NameNode(value: 'snapshotId')), + ) + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FragmentSpreadNode( + name: NameNode(value: 'basicMutationReturnFields'), + directives: [], + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + fragmentDefinitionbasicMutationReturnFields, +]); +Mutation$ForgetSnapshot _parserFn$Mutation$ForgetSnapshot( + Map data) => + Mutation$ForgetSnapshot.fromJson(data); +typedef OnMutationCompleted$Mutation$ForgetSnapshot = FutureOr Function( + Map?, + Mutation$ForgetSnapshot?, +); + +class Options$Mutation$ForgetSnapshot + extends graphql.MutationOptions { + Options$Mutation$ForgetSnapshot({ + String? operationName, + required Variables$Mutation$ForgetSnapshot variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Mutation$ForgetSnapshot? typedOptimisticResult, + graphql.Context? context, + OnMutationCompleted$Mutation$ForgetSnapshot? onCompleted, + graphql.OnMutationUpdate? update, + graphql.OnError? onError, + }) : onCompletedWithParsed = onCompleted, + super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + context: context, + onCompleted: onCompleted == null + ? null + : (data) => onCompleted( + data, + data == null + ? null + : _parserFn$Mutation$ForgetSnapshot(data), + ), + update: update, + onError: onError, + document: documentNodeMutationForgetSnapshot, + parserFn: _parserFn$Mutation$ForgetSnapshot, + ); + + final OnMutationCompleted$Mutation$ForgetSnapshot? onCompletedWithParsed; + + @override + List get properties => [ + ...super.onCompleted == null + ? super.properties + : super.properties.where((property) => property != onCompleted), + onCompletedWithParsed, + ]; +} + +class WatchOptions$Mutation$ForgetSnapshot + extends graphql.WatchQueryOptions { + WatchOptions$Mutation$ForgetSnapshot({ + String? operationName, + required Variables$Mutation$ForgetSnapshot variables, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Mutation$ForgetSnapshot? typedOptimisticResult, + graphql.Context? context, + Duration? pollInterval, + bool? eagerlyFetchResults, + bool carryForwardDataOnException = true, + bool fetchResults = false, + }) : super( + variables: variables.toJson(), + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult ?? typedOptimisticResult?.toJson(), + context: context, + document: documentNodeMutationForgetSnapshot, + pollInterval: pollInterval, + eagerlyFetchResults: eagerlyFetchResults, + carryForwardDataOnException: carryForwardDataOnException, + fetchResults: fetchResults, + parserFn: _parserFn$Mutation$ForgetSnapshot, + ); +} + +extension ClientExtension$Mutation$ForgetSnapshot on graphql.GraphQLClient { + Future> mutate$ForgetSnapshot( + Options$Mutation$ForgetSnapshot options) async => + await this.mutate(options); + graphql.ObservableQuery watchMutation$ForgetSnapshot( + WatchOptions$Mutation$ForgetSnapshot options) => + this.watchMutation(options); +} + +class Mutation$ForgetSnapshot$backup { + Mutation$ForgetSnapshot$backup({ + required this.forgetSnapshot, + this.$__typename = 'BackupMutations', + }); + + factory Mutation$ForgetSnapshot$backup.fromJson(Map json) { + final l$forgetSnapshot = json['forgetSnapshot']; + final l$$__typename = json['__typename']; + return Mutation$ForgetSnapshot$backup( + forgetSnapshot: Mutation$ForgetSnapshot$backup$forgetSnapshot.fromJson( + (l$forgetSnapshot as Map)), + $__typename: (l$$__typename as String), + ); + } + + final Mutation$ForgetSnapshot$backup$forgetSnapshot forgetSnapshot; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$forgetSnapshot = forgetSnapshot; + _resultData['forgetSnapshot'] = l$forgetSnapshot.toJson(); + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$forgetSnapshot = forgetSnapshot; + final l$$__typename = $__typename; + return Object.hashAll([ + l$forgetSnapshot, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Mutation$ForgetSnapshot$backup) || + runtimeType != other.runtimeType) { + return false; + } + final l$forgetSnapshot = forgetSnapshot; + final lOther$forgetSnapshot = other.forgetSnapshot; + if (l$forgetSnapshot != lOther$forgetSnapshot) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Mutation$ForgetSnapshot$backup + on Mutation$ForgetSnapshot$backup { + CopyWith$Mutation$ForgetSnapshot$backup + get copyWith => CopyWith$Mutation$ForgetSnapshot$backup( + this, + (i) => i, + ); +} + +abstract class CopyWith$Mutation$ForgetSnapshot$backup { + factory CopyWith$Mutation$ForgetSnapshot$backup( + Mutation$ForgetSnapshot$backup instance, + TRes Function(Mutation$ForgetSnapshot$backup) then, + ) = _CopyWithImpl$Mutation$ForgetSnapshot$backup; + + factory CopyWith$Mutation$ForgetSnapshot$backup.stub(TRes res) = + _CopyWithStubImpl$Mutation$ForgetSnapshot$backup; + + TRes call({ + Mutation$ForgetSnapshot$backup$forgetSnapshot? forgetSnapshot, + String? $__typename, + }); + CopyWith$Mutation$ForgetSnapshot$backup$forgetSnapshot + get forgetSnapshot; +} + +class _CopyWithImpl$Mutation$ForgetSnapshot$backup + implements CopyWith$Mutation$ForgetSnapshot$backup { + _CopyWithImpl$Mutation$ForgetSnapshot$backup( + this._instance, + this._then, + ); + + final Mutation$ForgetSnapshot$backup _instance; + + final TRes Function(Mutation$ForgetSnapshot$backup) _then; + + static const _undefined = {}; + + TRes call({ + Object? forgetSnapshot = _undefined, + Object? $__typename = _undefined, + }) => + _then(Mutation$ForgetSnapshot$backup( + forgetSnapshot: forgetSnapshot == _undefined || forgetSnapshot == null + ? _instance.forgetSnapshot + : (forgetSnapshot as Mutation$ForgetSnapshot$backup$forgetSnapshot), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); + CopyWith$Mutation$ForgetSnapshot$backup$forgetSnapshot + get forgetSnapshot { + final local$forgetSnapshot = _instance.forgetSnapshot; + return CopyWith$Mutation$ForgetSnapshot$backup$forgetSnapshot( + local$forgetSnapshot, (e) => call(forgetSnapshot: e)); + } +} + +class _CopyWithStubImpl$Mutation$ForgetSnapshot$backup + implements CopyWith$Mutation$ForgetSnapshot$backup { + _CopyWithStubImpl$Mutation$ForgetSnapshot$backup(this._res); + + TRes _res; + + call({ + Mutation$ForgetSnapshot$backup$forgetSnapshot? forgetSnapshot, + String? $__typename, + }) => + _res; + CopyWith$Mutation$ForgetSnapshot$backup$forgetSnapshot + get forgetSnapshot => + CopyWith$Mutation$ForgetSnapshot$backup$forgetSnapshot.stub(_res); +} + +class Mutation$ForgetSnapshot$backup$forgetSnapshot + implements Fragment$basicMutationReturnFields$$GenericMutationReturn { + Mutation$ForgetSnapshot$backup$forgetSnapshot({ + required this.code, + required this.message, + required this.success, + this.$__typename = 'GenericMutationReturn', + }); + + factory Mutation$ForgetSnapshot$backup$forgetSnapshot.fromJson( + Map json) { + final l$code = json['code']; + final l$message = json['message']; + final l$success = json['success']; + final l$$__typename = json['__typename']; + return Mutation$ForgetSnapshot$backup$forgetSnapshot( + code: (l$code as int), + message: (l$message as String), + success: (l$success as bool), + $__typename: (l$$__typename as String), + ); + } + + final int code; + + final String message; + + final bool success; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$code = code; + _resultData['code'] = l$code; + final l$message = message; + _resultData['message'] = l$message; + final l$success = success; + _resultData['success'] = l$success; + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$code = code; + final l$message = message; + final l$success = success; + final l$$__typename = $__typename; + return Object.hashAll([ + l$code, + l$message, + l$success, + l$$__typename, + ]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Mutation$ForgetSnapshot$backup$forgetSnapshot) || + runtimeType != other.runtimeType) { + return false; + } + final l$code = code; + final lOther$code = other.code; + if (l$code != lOther$code) { + return false; + } + final l$message = message; + final lOther$message = other.message; + if (l$message != lOther$message) { + return false; + } + final l$success = success; + final lOther$success = other.success; + if (l$success != lOther$success) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Mutation$ForgetSnapshot$backup$forgetSnapshot + on Mutation$ForgetSnapshot$backup$forgetSnapshot { + CopyWith$Mutation$ForgetSnapshot$backup$forgetSnapshot< + Mutation$ForgetSnapshot$backup$forgetSnapshot> + get copyWith => CopyWith$Mutation$ForgetSnapshot$backup$forgetSnapshot( + this, + (i) => i, + ); +} + +abstract class CopyWith$Mutation$ForgetSnapshot$backup$forgetSnapshot { + factory CopyWith$Mutation$ForgetSnapshot$backup$forgetSnapshot( + Mutation$ForgetSnapshot$backup$forgetSnapshot instance, + TRes Function(Mutation$ForgetSnapshot$backup$forgetSnapshot) then, + ) = _CopyWithImpl$Mutation$ForgetSnapshot$backup$forgetSnapshot; + + factory CopyWith$Mutation$ForgetSnapshot$backup$forgetSnapshot.stub( + TRes res) = + _CopyWithStubImpl$Mutation$ForgetSnapshot$backup$forgetSnapshot; + + TRes call({ + int? code, + String? message, + bool? success, + String? $__typename, + }); +} + +class _CopyWithImpl$Mutation$ForgetSnapshot$backup$forgetSnapshot + implements CopyWith$Mutation$ForgetSnapshot$backup$forgetSnapshot { + _CopyWithImpl$Mutation$ForgetSnapshot$backup$forgetSnapshot( + this._instance, + this._then, + ); + + final Mutation$ForgetSnapshot$backup$forgetSnapshot _instance; + + final TRes Function(Mutation$ForgetSnapshot$backup$forgetSnapshot) _then; + + static const _undefined = {}; + + TRes call({ + Object? code = _undefined, + Object? message = _undefined, + Object? success = _undefined, + Object? $__typename = _undefined, + }) => + _then(Mutation$ForgetSnapshot$backup$forgetSnapshot( + code: + code == _undefined || code == null ? _instance.code : (code as int), + message: message == _undefined || message == null + ? _instance.message + : (message as String), + success: success == _undefined || success == null + ? _instance.success + : (success as bool), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + )); +} + +class _CopyWithStubImpl$Mutation$ForgetSnapshot$backup$forgetSnapshot + implements CopyWith$Mutation$ForgetSnapshot$backup$forgetSnapshot { + _CopyWithStubImpl$Mutation$ForgetSnapshot$backup$forgetSnapshot(this._res); + + TRes _res; + + call({ + int? code, + String? message, + bool? success, + String? $__typename, + }) => + _res; +} diff --git a/lib/logic/api_maps/graphql_maps/server_api/backups_api.dart b/lib/logic/api_maps/graphql_maps/server_api/backups_api.dart index 3d629cb7..ed54bd53 100644 --- a/lib/logic/api_maps/graphql_maps/server_api/backups_api.dart +++ b/lib/logic/api_maps/graphql_maps/server_api/backups_api.dart @@ -248,4 +248,42 @@ mixin BackupsApi on GraphQLApiMap { return result; } + + Future> forgetSnapshot( + final String snapshotId, + ) async { + QueryResult response; + GenericResult? result; + + try { + final GraphQLClient client = await getClient(); + final variables = Variables$Mutation$ForgetSnapshot( + snapshotId: snapshotId, + ); + final options = Options$Mutation$ForgetSnapshot(variables: variables); + response = await client.mutate$ForgetSnapshot(options); + if (response.hasException) { + final message = response.exception.toString(); + print(message); + result = GenericResult( + success: false, + data: null, + message: message, + ); + } + result = GenericResult( + success: true, + data: response.parsedData!.backup.forgetSnapshot.success, + ); + } catch (e) { + print(e); + result = GenericResult( + success: false, + data: null, + message: e.toString(), + ); + } + + return result; + } } diff --git a/lib/logic/cubit/backups/backups_cubit.dart b/lib/logic/cubit/backups/backups_cubit.dart index 300a898b..1d416033 100644 --- a/lib/logic/cubit/backups/backups_cubit.dart +++ b/lib/logic/cubit/backups/backups_cubit.dart @@ -214,6 +214,20 @@ class BackupsCubit extends ServerInstallationDependendCubit { await updateBackups(); } + // TODO: inex + Future forgetSnapshot(final String snapshotId) async { + final result = await api.forgetSnapshot(snapshotId); + if (!result.success) { + getIt().showSnackBar('jobs.generic_error'.tr()); + return; + } + + if (result.data == false) { + getIt() + .showSnackBar('backup.forget_snapshot_error'.tr()); + } + } + @override void clear() async { emit(const BackupsState());