From 7896375898a89be611efdbd099a792e7167ec372 Mon Sep 17 00:00:00 2001 From: WalidMoovin Date: Thu, 16 Mar 2023 17:37:10 +0100 Subject: [PATCH] leavechannel --- front/volume/src/components/Chat.svelte | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/front/volume/src/components/Chat.svelte b/front/volume/src/components/Chat.svelte index 0b02be8..1ab7fb5 100644 --- a/front/volume/src/components/Chat.svelte +++ b/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"); + } + } + } + + //--------------------------------------------------------------------------------/
@@ -333,6 +350,7 @@ send +