From 6eb2b6d31a6a95417bab51cb9602edb635c0554c Mon Sep 17 00:00:00 2001
From: Thomas Citharel
Date: Fri, 6 May 2022 13:09:38 +0200
Subject: [PATCH] Better display of the errors when adding an instance
Signed-off-by: Thomas Citharel
---
js/src/views/Admin/Instances.vue | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/js/src/views/Admin/Instances.vue b/js/src/views/Admin/Instances.vue
index 2431409fa..12e14c412 100644
--- a/js/src/views/Admin/Instances.vue
+++ b/js/src/views/Admin/Instances.vue
@@ -21,6 +21,11 @@
{{
$t("Add an instance")
}}
+
@@ -171,7 +176,6 @@ import {
InstanceFilterFollowStatus,
InstanceFollowStatus,
} from "@/types/enums";
-import { SnackbarProgrammatic as Snackbar } from "buefy";
const { isNavigationFailure, NavigationFailureType } = VueRouter;
const INSTANCES_PAGE_LIMIT = 10;
@@ -203,6 +207,8 @@ const INSTANCES_PAGE_LIMIT = 10;
export default class Follows extends Vue {
RouteName = RouteName;
+ followInstanceLoading = false;
+
newRelayAddress = "";
instances!: Paginate;
@@ -257,6 +263,7 @@ export default class Follows extends Vue {
async followInstance(e: Event): Promise {
e.preventDefault();
+ this.followInstanceLoading = true;
const domain = this.newRelayAddress.trim(); // trim to fix copy and paste domain name spaces and tabs
try {
await this.$apollo.mutate<{ relayFollowings: Paginate }>({
@@ -266,18 +273,18 @@ export default class Follows extends Vue {
},
});
this.newRelayAddress = "";
+ this.followInstanceLoading = false;
this.$router.push({
name: RouteName.INSTANCE,
params: { domain },
});
- } catch (err: any) {
- if (err.message) {
- Snackbar.open({
- message: err.message,
- type: "is-danger",
- position: "is-bottom",
- });
+ } catch (error: any) {
+ if (error.message) {
+ if (error.graphQLErrors && error.graphQLErrors.length > 0) {
+ this.$notifier.error(error.graphQLErrors[0].message);
+ }
}
+ this.followInstanceLoading = false;
}
}