mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-09 17:39:42 +00:00
refactor: Remove unused job
This commit is contained in:
parent
7bb96b5ed0
commit
160e6d3b35
|
@ -132,20 +132,51 @@ class ServerApi extends GraphQLApiMap
|
||||||
return usesBinds;
|
return usesBinds;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> switchService(final String uid, final bool needTurnOn) async {
|
Future<GenericResult> switchService(
|
||||||
|
final String uid,
|
||||||
|
final bool needTurnOn,
|
||||||
|
) async {
|
||||||
try {
|
try {
|
||||||
final GraphQLClient client = await getClient();
|
final GraphQLClient client = await getClient();
|
||||||
if (needTurnOn) {
|
if (needTurnOn) {
|
||||||
final variables = Variables$Mutation$EnableService(serviceId: uid);
|
final variables = Variables$Mutation$EnableService(serviceId: uid);
|
||||||
final mutation = Options$Mutation$EnableService(variables: variables);
|
final mutation = Options$Mutation$EnableService(variables: variables);
|
||||||
await client.mutate$EnableService(mutation);
|
final result = await client.mutate$EnableService(mutation);
|
||||||
|
if (result.hasException) {
|
||||||
|
return GenericResult(
|
||||||
|
success: false,
|
||||||
|
message: result.exception.toString(),
|
||||||
|
data: null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return GenericResult(
|
||||||
|
success: result.parsedData?.services.enableService.success ?? false,
|
||||||
|
message: result.parsedData?.services.enableService.message,
|
||||||
|
data: null,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
final variables = Variables$Mutation$DisableService(serviceId: uid);
|
final variables = Variables$Mutation$DisableService(serviceId: uid);
|
||||||
final mutation = Options$Mutation$DisableService(variables: variables);
|
final mutation = Options$Mutation$DisableService(variables: variables);
|
||||||
await client.mutate$DisableService(mutation);
|
final result = await client.mutate$DisableService(mutation);
|
||||||
|
if (result.hasException) {
|
||||||
|
return GenericResult(
|
||||||
|
success: false,
|
||||||
|
message: result.exception.toString(),
|
||||||
|
data: null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return GenericResult(
|
||||||
|
success: result.parsedData?.services.disableService.success ?? false,
|
||||||
|
message: result.parsedData?.services.disableService.message,
|
||||||
|
data: null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
return GenericResult(
|
||||||
|
success: false,
|
||||||
|
message: e.toString(),
|
||||||
|
data: null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,29 +36,6 @@ abstract class ClientJob extends Equatable {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated('Jobs bloc should handle it itself')
|
|
||||||
class RebuildServerJob extends ClientJob {
|
|
||||||
RebuildServerJob({
|
|
||||||
required super.title,
|
|
||||||
super.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool canAddTo(final List<ClientJob> jobs) =>
|
|
||||||
!jobs.any((final job) => job is RebuildServerJob);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<(bool, String)> execute() async => (false, 'unimplemented');
|
|
||||||
|
|
||||||
@override
|
|
||||||
RebuildServerJob copyWithNewStatus({
|
|
||||||
required final JobStatusEnum status,
|
|
||||||
final String? message,
|
|
||||||
}) {
|
|
||||||
throw UnimplementedError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class UpgradeServerJob extends ClientJob {
|
class UpgradeServerJob extends ClientJob {
|
||||||
UpgradeServerJob({
|
UpgradeServerJob({
|
||||||
super.status,
|
super.status,
|
||||||
|
@ -228,10 +205,10 @@ class ServiceToggleJob extends ClientJob {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<(bool, String)> execute() async {
|
Future<(bool, String)> execute() async {
|
||||||
await getIt<ApiConnectionRepository>()
|
final result = await getIt<ApiConnectionRepository>()
|
||||||
.api
|
.api
|
||||||
.switchService(service.id, needToTurnOn);
|
.switchService(service.id, needToTurnOn);
|
||||||
return (true, 'Check not implemented');
|
return (result.success, result.message ?? 'jobs.generic_error'.tr());
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
Loading…
Reference in a new issue