From f43ecc98aae8c61bb79f0e2af1d6bbc8346ae9b5 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sun, 5 Nov 2023 08:29:36 -0700 Subject: [PATCH] tweak notifications on errors and other responses --- project.task.yaml | 1 - src/views/AccountViewView.vue | 9 ++- src/views/ContactsView.vue | 101 ++++++++++++++++------------------ 3 files changed, 55 insertions(+), 56 deletions(-) diff --git a/project.task.yaml b/project.task.yaml index be6d7e6e..ce7734da 100644 --- a/project.task.yaml +++ b/project.task.yaml @@ -6,7 +6,6 @@ tasks: - 40 notifications : - push, where we trigger a ServiceWorker(?) in the app to reach out and check for new data assignee:matthew -- 01 bug - we get a 404 when reloading the page anyplace except "/", and it's hard to get back - .1 test - make sure that a registration failure (including network failure) doesn't give a success message (which may have happened during board meeting) - .1 don't allow to even see the claim actions if they're not registered diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index aafb7cb9..c15141b0 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -729,8 +729,13 @@ export default class AccountViewView extends Vue { private handleRateLimitsError(error: unknown) { if (error instanceof AxiosError) { const data = error.response?.data as ErrorResponse; - this.limitsMessage = data?.error?.message || "Bad server response."; - console.error("Bad response retrieving limits:", error); + this.limitsMessage = + (data?.error?.message as string) || "Bad server response."; + console.log( + "Got bad response retrieving limits, which usually means user isn't registered. Server says:", + this.limitsMessage, + //error, + ); } else if ( error instanceof Error && error.message === diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index 7c0a81e0..0caf7545 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -394,7 +394,7 @@ export default class ContactsView extends Vue { { group: "alert", type: "danger", - title: "Error With Server", + title: "Server Error", text: "Got an error retrieving your " + (useRecipient ? "given" : "received") + @@ -453,7 +453,7 @@ export default class ContactsView extends Vue { { group: "alert", type: "danger", - title: "Error With Server", + title: "Server Error", text: error as string, }, -1, @@ -589,6 +589,16 @@ export default class ContactsView extends Vue { "?", ) ) { + this.$notify( + { + group: "alert", + type: "toast", + text: "", + title: "Registration submitted...", + }, + 1000, + ); + const identity = await this.getIdentity(this.activeDid); const vcClaim: RegisterVerifiableCredential = { @@ -671,7 +681,7 @@ export default class ContactsView extends Vue { { group: "alert", type: "danger", - title: "Error With Server", + title: "Server Error", text: userMessage, }, -1, @@ -696,36 +706,30 @@ export default class ContactsView extends Vue { contact.seesMe = visibility; db.contacts.update(contact.did, { seesMe: visibility }); } else { - console.error("Bad response setting visibility: ", resp.data); - if (resp.data.error?.message) { - this.$notify( - { - group: "alert", - type: "danger", - title: "Error With Server", - text: resp.data.error?.message, - }, - -1, - ); - } else { - this.$notify( - { - group: "alert", - type: "danger", - title: "Error With Server", - text: "Bad server response of " + resp.status, - }, - -1, - ); - } + console.error( + "Got some bad server response when setting visibility: ", + resp, + ); + const message = + resp.data.error?.message || "Bad server response of " + resp.status; + this.$notify( + { + group: "alert", + type: "danger", + title: "Server Error", + text: message, + }, + -1, + ); } } catch (err) { + console.error("Got some server error when setting visibility:", err); this.$notify( { group: "alert", type: "danger", - title: "Error With Server", - text: err as string, + title: "Server Error", + text: "Check connectivity and try again.", }, -1, ); @@ -750,7 +754,7 @@ export default class ContactsView extends Vue { this.$notify( { group: "alert", - type: "toast", + type: "info", title: "Refreshed", text: this.nameForContact(contact, true) + @@ -758,38 +762,29 @@ export default class ContactsView extends Vue { (visibility ? "" : "not ") + "see your activity.", }, - 5000, + -1, ); } else { - if (resp.data.error?.message) { - this.$notify( - { - group: "alert", - type: "danger", - title: "Error With Server", - text: resp.data.error?.message, - }, - -1, - ); - } else { - this.$notify( - { - group: "alert", - type: "danger", - title: "Error With Server", - text: "Bad server response of " + resp.status, - }, - -1, - ); - } + const message = + resp.data.error?.message || "Bad server response of " + resp.status; + this.$notify( + { + group: "alert", + type: "danger", + title: "Server Error", + text: resp.data.error?.message, + }, + -1, + ); } } catch (err) { + console.log("Caught error from server request to check visibility:", err); this.$notify( { group: "alert", type: "danger", - title: "Error With Server", - text: err as string, + title: "Server Error", + text: "Check connectivity and try again.", }, -1, ); @@ -989,7 +984,7 @@ export default class ContactsView extends Vue { { group: "alert", type: "danger", - title: "Error With Server", + title: "Server Error", text: userMessage, }, -1,