Skip to content

Commit

Permalink
add error toast for saving settings and retrying builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas-Heiligenbrunner committed Oct 25, 2024
1 parent 1a8105e commit 72d8ed2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
23 changes: 16 additions & 7 deletions frontend/lib/screens/Package_settings_screen.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'package:aurcache/api/packages.dart';
import 'package:aurcache/components/build_flag_settings.dart';
import 'package:aurcache/components/platform_settings.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_tags_x/flutter_tags_x.dart';
import 'package:provider/provider.dart';
import 'package:toastification/toastification.dart';

import '../api/API.dart';
import '../components/api/APIBuilder.dart';
import '../constants/platforms.dart';
import '../models/extended_package.dart';
import '../providers/api/package_provider.dart';

Expand All @@ -34,11 +34,20 @@ class _PackagesettingsscreenState extends State<Packagesettingsscreen> {
padding: const EdgeInsets.only(right: 10),
child: TextButton(
onPressed: () async {
await API.patchPackage(
id: widget.pkgID,
build_flags: buildFlags,
platforms: buildPlatforms);
Navigator.pop(context);
try {
await API.patchPackage(
id: widget.pkgID,
build_flags: buildFlags,
platforms: buildPlatforms);
Navigator.pop(context);
} on DioException catch (e) {
print(e);
toastification.show(
title: Text('Failed to save package settings!'),
autoCloseDuration: const Duration(seconds: 5),
type: ToastificationType.error,
);
}
},
child: const Text("Save")),
)
Expand Down
16 changes: 13 additions & 3 deletions frontend/lib/screens/build_screen.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import 'package:aurcache/api/builds.dart';
import 'package:aurcache/api/packages.dart';
import 'package:aurcache/components/build_output.dart';
import 'package:aurcache/models/build.dart';
import 'package:aurcache/components/api/APIBuilder.dart';
import 'package:aurcache/providers/build_log_provider.dart';
import 'package:aurcache/utils/time_formatter.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:provider/provider.dart';
import 'package:toastification/toastification.dart';

import '../api/API.dart';
import '../components/confirm_popup.dart';
Expand Down Expand Up @@ -267,8 +268,17 @@ class _BuildScreenState extends State<BuildScreen> {
),
ElevatedButton(
onPressed: () async {
final buildid = await API.retryBuild(id: build.id);
context.pushReplacement("/build/$buildid");
try {
final buildid = await API.retryBuild(id: build.id);
context.pushReplacement("/build/$buildid");
} on DioException catch (e) {
print(e);
toastification.show(
title: Text('Failed to retry build!'),
autoCloseDuration: const Duration(seconds: 5),
type: ToastificationType.error,
);
}
},
child: const Text(
"Retry",
Expand Down

0 comments on commit 72d8ed2

Please sign in to comment.