From a5aeb6f32474d954ef37e0854cfc8a3bb5ae80e2 Mon Sep 17 00:00:00 2001 From: Hugh Nimmo-Smith Date: Wed, 11 Sep 2024 14:53:50 +0100 Subject: [PATCH] Give user feedback if the rageshake submission failed (#2621) --- src/settings/FeedbackSettingsTab.tsx | 13 +++++-------- src/settings/submit-rageshake.ts | 8 +++++++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/settings/FeedbackSettingsTab.tsx b/src/settings/FeedbackSettingsTab.tsx index f47d10ac2..afefe07eb 100644 --- a/src/settings/FeedbackSettingsTab.tsx +++ b/src/settings/FeedbackSettingsTab.tsx @@ -69,9 +69,7 @@ export const FeedbackSettingsTab: FC = ({ roomId }) => { disabled={sending || sent} /> - {sent ? ( - {t("settings.feedback_tab_thank_you")} - ) : ( + {!sent && ( = ({ roomId }) => { type="checkbox" defaultChecked /> - {error && ( - - - - )} )} + + {error && } + {sent && {t("settings.feedback_tab_thank_you")}} + ); diff --git a/src/settings/submit-rageshake.ts b/src/settings/submit-rageshake.ts index 16b81d0b6..1ab906672 100644 --- a/src/settings/submit-rageshake.ts +++ b/src/settings/submit-rageshake.ts @@ -270,11 +270,17 @@ export function useSubmitRageshake(): { ); } - await fetch(Config.get().rageshake!.submit_url, { + const res = await fetch(Config.get().rageshake!.submit_url, { method: "POST", body, }); + if (res.status !== 200) { + throw new Error( + `Failed to submit feedback: receive HTTP ${res.status} ${res.statusText}`, + ); + } + setState({ sending: false, sent: true, error: undefined }); } catch (error) { setState({ sending: false, sent: false, error: error as Error });