Browse Source

fix chan creation with a name already used

master
nicolas-arnaud 2 years ago
parent
commit
0eda6f00df
  1. 12
      front/src/components/Channels.svelte

12
front/src/components/Channels.svelte

@ -73,14 +73,6 @@
let channelMode = ""; let channelMode = "";
const channelOptions = ["public", "private", "protected"]; const channelOptions = ["public", "private", "protected"];
const checkNamesChannel= (name : string) => {
channels.forEach((e) => {
if (e.name == name)
return false;
});
return true;
}
const getChannels = async () => { const getChannels = async () => {
const res = await fetch(API_URL + "/channels", { const res = await fetch(API_URL + "/channels", {
credentials: "include", credentials: "include",
@ -113,8 +105,8 @@
await show_popup("Channel name cannot contain #", false) await show_popup("Channel name cannot contain #", false)
return; return;
} }
if (!checkNamesChannel(name)) { if (channels.some((chan) => chan.name === name)) {
await show_popup("User may not have access", false) await show_popup("A channel with this name already exist", false)
return; return;
} }
if (name) { if (name) {

Loading…
Cancel
Save