Browse Source

error feedback

master
nicolas-arnaud 2 years ago
parent
commit
60a3bcb494
  1. 5
      front/volume/src/components/Alert/content.ts
  2. 21
      front/volume/src/components/Channels.svelte
  3. 40
      front/volume/src/components/Chat.svelte

5
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()
}
}

21
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()
};

40
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"; </script>
import type User from "./Profile.svelte";
</script>
<script lang="ts">
export let channel: ChannelsType;
@ -168,7 +169,10 @@
});
}
if (response.ok) await show_popup("User blocked", false);
else await show_popup("Failed to block user", false);
else {
const error = await response.json();
await show_popup(error.message, false);
}
};
//--------------------------------------------------------------------------------/
@ -187,7 +191,10 @@
});
}
if (response.ok) await show_popup("User unblocked", false);
else await show_popup("Failed to unblock user", false);
else {
const error = await response.json();
await show_popup(error.message, false);
}
};
//--------------------------------------------------------------------------------/
@ -213,8 +220,12 @@
body: JSON.stringify({ data: [target.ftId, duration] }),
});
if (response.ok) {
socket.emit("kickUser", {chan: channel.id, from: $store.ftId, to: target.ftId});
} else await show_popup(`Ban of ${username}: ${await response.text()}`, false);
await show_popup(`User banned for: ${duration} seconds`, false);
socket.emit("kickUser", channel.id, $store.ftId, target.ftId);
} else {
const error = await response.json();
await show_popup(error.message, false);
}
}
};
@ -238,7 +249,10 @@
});
}
if (response.ok) await show_popup("User unbanned", false);
else await show_popup("Failed to unban user", false);
else {
const error = await response.json();
await show_popup(error.message, false);
}
};
//--------------------------------------------------------------------------------/
@ -256,7 +270,8 @@
to: target.ftId,
});
} else {
await show_popup("Failed to kick: " + await response.text(), false);
const error = await response.json();
await show_popup(error.message, false);
}
};
@ -281,7 +296,10 @@
});
}
if (response.ok) await show_popup("User muted", false);
else await show_popup("Failed to mute user", false);
else {
const error = await response.json()
await show_popup(error.message, false);
}
};
//--------------------------------------------------------------------------------/
@ -306,7 +324,8 @@
if (response.ok) {
await show_popup("User promoted", false);
} else {
await show_popup("Failed to promote user", false);
const error = await response.json();
await show_popup(error.message, false);
}
};
@ -332,7 +351,8 @@
if (response.ok) {
await show_popup("User demoted", false);
} else {
await show_popup("Failed to demote user", false);
const error = await response.json();
await show_popup(error.message, false);
}
};

Loading…
Cancel
Save