Skip to content

Commit

Permalink
Give user feedback if the rageshake submission failed (#2621)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughns authored Sep 11, 2024
1 parent 5fda7fa commit a5aeb6f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/settings/FeedbackSettingsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ export const FeedbackSettingsTab: FC<Props> = ({ roomId }) => {
disabled={sending || sent}
/>
</FieldRow>
{sent ? (
<Body> {t("settings.feedback_tab_thank_you")}</Body>
) : (
{!sent && (
<FieldRow>
<InputField
id="sendLogs"
Expand All @@ -80,16 +78,15 @@ export const FeedbackSettingsTab: FC<Props> = ({ roomId }) => {
type="checkbox"
defaultChecked
/>
{error && (
<FieldRow>
<ErrorMessage error={error} />
</FieldRow>
)}
<Button type="submit" disabled={sending}>
{sending ? t("submitting") : t("action.submit")}
</Button>
</FieldRow>
)}
<FieldRow>
{error && <ErrorMessage error={error} />}
{sent && <Body> {t("settings.feedback_tab_thank_you")}</Body>}
</FieldRow>
</form>
</div>
);
Expand Down
8 changes: 7 additions & 1 deletion src/settings/submit-rageshake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down

0 comments on commit a5aeb6f

Please sign in to comment.