From 60a3bcb4943d3e653bc687ef8a8b321dd1f5d665 Mon Sep 17 00:00:00 2001 From: nicolas-arnaud Date: Mon, 20 Mar 2023 15:43:26 +0100 Subject: [PATCH] error feedback --- front/volume/src/components/Alert/content.ts | 5 ++- front/volume/src/components/Channels.svelte | 21 ++++++---- front/volume/src/components/Chat.svelte | 40 +++++++++++++++----- 3 files changed, 47 insertions(+), 19 deletions(-) diff --git a/front/volume/src/components/Alert/content.ts b/front/volume/src/components/Alert/content.ts index 886f29d..3a61ec4 100644 --- a/front/volume/src/components/Alert/content.ts +++ b/front/volume/src/components/Alert/content.ts @@ -10,7 +10,8 @@ export async function show_popup(message, form = true) { message, form })) - await waitForCondition() + await waitForCondition() + await waitForCondition() } export async function waitForCondition() { @@ -27,4 +28,4 @@ export async function waitForCondition() { } } return checkFlag() -} \ No newline at end of file +} diff --git a/front/volume/src/components/Channels.svelte b/front/volume/src/components/Channels.svelte index a1b721f..33f8f44 100644 --- a/front/volume/src/components/Channels.svelte +++ b/front/volume/src/components/Channels.svelte @@ -136,8 +136,10 @@ isPrivate: channelMode === "private", }), }); - if (!response.ok) - await show_popup("Error creating channel", false) + if (!response.ok) { + const error = await response.json(); + await show_popup(error.message, false) + } getChannels() } else await show_popup("Channel name is required", false) }; @@ -153,8 +155,10 @@ mode: "cors", }); if (response.ok) channels = channels.filter((c) => c.id !== id); - else - await show_popup("Error deleting channel", false) + else { + const error = await response.json(); + await show_popup(error.message, false) + } } }; @@ -184,10 +188,12 @@ if (response2.ok) { await show_popup("User invited", false) } else { - await show_popup("Error inviting user", false) + const error = await response2.json(); + await show_popup(error.message, false) } } else { - await show_popup("Error getting user infos", false) + const error = await response.json(); + await show_popup(error.message, false) } }; @@ -208,7 +214,8 @@ }), }); if (!response.ok) { - await show_popup("Error changing password", false) + const error = await response.json(); + await show_popup(error.message, false) } else getChannels() }; diff --git a/front/volume/src/components/Chat.svelte b/front/volume/src/components/Chat.svelte index 2b72154..d7b4f34 100644 --- a/front/volume/src/components/Chat.svelte +++ b/front/volume/src/components/Chat.svelte @@ -5,7 +5,8 @@ import { show_popup, content } from "./Alert/content"; import { APPSTATE } from "../App.svelte"; import { formatChannelNames, type ChannelsType, type chatMessagesType } from "./Channels.svelte"; - import type User from "./Profile.svelte"; + import type User from "./Profile.svelte"; +