Browse Source

leavechannel

master
WalidMoovin 2 years ago
parent
commit
7896375898
  1. 18
      front/volume/src/components/Chat.svelte

18
front/volume/src/components/Chat.svelte

@ -265,6 +265,23 @@
}; };
//--------------------------------------------------------------------------------/ //--------------------------------------------------------------------------------/
const leaveChannel = async () => {
const prompt = window.prompt("Are you sure you want to leave this channel? (y/n)");
if (prompt == "y") {
const response = await fetch(API_URL + "/channels/" + channel.id + "/leave", {
credentials: "include",
mode: "cors",
});
if (response.ok) {
window.location.href = "/channels";
} else {
alert("Failed to leave channel");
}
}
}
//--------------------------------------------------------------------------------/
</script> </script>
<div class="overlay"> <div class="overlay">
@ -333,6 +350,7 @@
<img src="img/send.png" alt="send" /> <img src="img/send.png" alt="send" />
</button> </button>
</form> </form>
<button on:click={leaveChannel}>Leave</button>
<button <button
on:click|stopPropagation={toggleChatMembers} on:click|stopPropagation={toggleChatMembers}
on:keydown|stopPropagation on:keydown|stopPropagation

Loading…
Cancel
Save