Pheuw1 2 years ago
parent
commit
fd2b066b9f
  1. 5
      back/volume/src/chat/entity/channel.entity.ts
  2. 2
      front/volume/src/App.svelte
  3. 11
      front/volume/src/components/Channels.svelte
  4. 3
      front/volume/src/components/Chat.svelte

5
back/volume/src/chat/entity/channel.entity.ts

@ -13,6 +13,11 @@ import User from 'src/users/entity/user.entity'
import Message from './message.entity'
import * as bcrypt from 'bcrypt'
export interface Ban {
user: User
duration: number
}
@Entity()
export default class Channel {
@PrimaryGeneratedColumn()

2
front/volume/src/App.svelte

@ -167,7 +167,7 @@
let selectedChannel: ChannelsType;
const handleSelectChannel = (channel: ChannelsType) => {
selectedChannel = channel;
setAppState(APPSTATE.CHANNELS + "#" + channel.id);
setAppState(APPSTATE.CHANNELS + "#" + channel.name);
};
// GAME

11
front/volume/src/components/Channels.svelte

@ -56,7 +56,7 @@
<script lang="ts">
//--------------------------------------------------------------------------------/
let channelMode = "";
const channelOptions = ["public", "private"];
const channelOptions = ["public", "private", "protected"];
const joinChannel = async (id: number) => {
socket.emit("joinChannel", {
@ -100,10 +100,11 @@
const createChannel = async () => {
let name;
let password = "";
name = prompt("Enter a name for the new channel:");
if (name) {
let password = "";
password = prompt("Enter a password for the new channel:");
if (channelMode === 'protected')
password = prompt("Enter a password for the new channel:");
name = "🚪 " + name;
const response = await fetch(API_URL + "/channels", {
credentials: "include",
@ -212,12 +213,10 @@
on:click={() => removeChannel(channel.id)}
on:keydown={() => removeChannel(channel.id)}>🗑️</button
>
{#if channel.isPrivate == true}
{#if channel.isPrivate == false}
<button on:click={() => inviteChannel(channel.id)}>🤝</button>
{/if}
{#if channel.password !== ''}
<button on:click={() => changePassword(channel.id)}>🔑</button>
{/if}
</div>
</li>

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

@ -154,6 +154,7 @@
});
if (response.ok) {
const target = await response.json();
const duration = prompt("Enter a time for which the user will be banned from this channel")
response = await fetch(API_URL + "/channels/" + channel.id + "/ban", {
credentials: "include",
method: "POST",
@ -163,7 +164,7 @@
},
body: JSON.stringify({ id: target.ftId }),
});
socket.emit("kickUser", channel.id, $store.ftId, target.ftId);
socket.emit("kickUser", channel.id, $store.ftId, target.ftId, duration);
}
if (response.ok) {
alert("User banned");

Loading…
Cancel
Save