diff --git a/front/volume/src/components/Channels.svelte b/front/volume/src/components/Channels.svelte
index 4af5626..2f71ad3 100644
--- a/front/volume/src/components/Channels.svelte
+++ b/front/volume/src/components/Channels.svelte
@@ -8,7 +8,7 @@
}
import { onMount } from "svelte";
import { API_URL, store } from "../Auth";
- import { io } from "../socket";
+ import { socket } from "../socket";
@@ -25,16 +25,16 @@ import type User from "./Profile.svelte";
});
if (res.ok) blockedUsers = await res.json();
- io.on("messages", (msgs: Array) => {
+ socket.on("messages", (msgs: Array) => {
chatMessages = msgs;
});
- io.on("newMessage", (msg: chatMessagesType) => {
+ socket.on("newMessage", (msg: chatMessagesType) => {
chatMessages = [...chatMessages.slice(-5 + 1), msg];
});
onDestroy(() => {
- io.emit("leaveChannel", channel.id, $store.ftId);
+ socket.emit("leaveChannel", channel.id, $store.ftId);
});
});
@@ -48,7 +48,7 @@ import type User from "./Profile.svelte";
text: newText,
};
chatMessages = [...chatMessages.slice(-5 + 1)];
- io.emit("addMessage", channel.id, $store.ftId, newText);
+ socket.emit("addMessage", channel.id, $store.ftId, newText);
newText = "";
const messagesDiv = document.querySelector(".messages");
if (messagesDiv) {
@@ -135,7 +135,7 @@ import type User from "./Profile.svelte";
mode: "cors",
});
if (res2.ok) {
- io.emit("kickUser", channel.id, $store.ftId, data1.ftId);
+ socket.emit("kickUser", channel.id, $store.ftId, data1.ftId);
alert("User banned");
} else {
alert("Failed to ban user");
@@ -150,7 +150,7 @@ import type User from "./Profile.svelte";
mode: "cors",
});
const kickedUser = await res.json();
- io.emit("kickUser", channel.id, $store.ftId, kickedUser.ftId);
+ socket.emit("kickUser", channel.id, $store.ftId, kickedUser.ftId);
};
//--------------------------------------------------------------------------------/
diff --git a/front/volume/src/socket.ts b/front/volume/src/socket.ts
index ab94b4d..d7544bd 100644
--- a/front/volume/src/socket.ts
+++ b/front/volume/src/socket.ts
@@ -1,5 +1,3 @@
-import ioClient from "socket.io-client";
+import { io } from "socket.io-client";
-export const io = ioClient("http://localhost:3001", {
- withCredentials: true,
-});
+export const socket: Socket = io("http://localhost:3001");