diff --git a/back/volume/src/chat/chat.controller.ts b/back/volume/src/chat/chat.controller.ts index a3573cd..eda3ec6 100644 --- a/back/volume/src/chat/chat.controller.ts +++ b/back/volume/src/chat/chat.controller.ts @@ -84,8 +84,10 @@ export class ChatController { } @Get(':id/users') - async getUsersOfChannel (@Param('id') id: number): Promise { - return (await this.channelService.getChannel(id)).users + async getUsersOfChannel (@Param('id', ParseIntPipe) id: number): Promise { + let users = (await this.channelService.getFullChannel(id)).users + users.forEach((u) => u.socketKey = '') + return users; } @Post(':id/admin') @@ -252,7 +254,6 @@ export class ChatController { await this.channelService.save(channel) } - @Post() async createChannel (@Body() channel: CreateChannelDto): Promise { return await this.channelService.createChannel(channel) diff --git a/back/volume/src/chat/chat.gateway.ts b/back/volume/src/chat/chat.gateway.ts index fa262ce..b43cc23 100644 --- a/back/volume/src/chat/chat.gateway.ts +++ b/back/volume/src/chat/chat.gateway.ts @@ -89,7 +89,6 @@ export class ChatGateway implements OnGatewayConnection, OnGatewayDisconnect { const createdMessage: Message = await this.messageService.createMessage( message ) - console.log(createdMessage) this.server.to(channel.id.toString()).emit('newMessage', createdMessage) } diff --git a/back/volume/src/chat/chat.service.ts b/back/volume/src/chat/chat.service.ts index c89a267..c4068e8 100644 --- a/back/volume/src/chat/chat.service.ts +++ b/back/volume/src/chat/chat.service.ts @@ -129,12 +129,14 @@ export class ChatService { return channel } + // Warning: those channels users contains socketKey. + // they have to be hidden before returned from a route + // but not save them without the key. async getFullChannel (id: number): Promise { const channel = await this.ChannelRepository.findOne({ where: { id }, relations: ['users', 'admins', 'banned', 'owner'] }) - if (channel == null) { throw new BadRequestException(`Channel #${id} not found`) } diff --git a/front/volume/src/components/Chat.svelte b/front/volume/src/components/Chat.svelte index 1ab7fb5..ef8d88f 100644 --- a/front/volume/src/components/Chat.svelte +++ b/front/volume/src/components/Chat.svelte @@ -12,6 +12,7 @@ -
@@ -371,12 +388,8 @@ - - + +

{/each} diff --git a/front/volume/src/components/Friends.svelte b/front/volume/src/components/Friends.svelte index dd62aa7..5568d87 100644 --- a/front/volume/src/components/Friends.svelte +++ b/front/volume/src/components/Friends.svelte @@ -92,7 +92,7 @@

Add a friend

- +
diff --git a/front/volume/src/components/MatchHistory.svelte b/front/volume/src/components/MatchHistory.svelte index f6b171c..b7c9445 100644 --- a/front/volume/src/components/MatchHistory.svelte +++ b/front/volume/src/components/MatchHistory.svelte @@ -35,20 +35,22 @@ }); } } - let tmp = await response.json(); - newBatch = tmp.data.map((match: Match) => { - return { - players: match.players, - score: match.score, - date: new Date(match.date).toLocaleString("fr-FR", { - timeZone: "Europe/Paris", - dateStyle: "short", - timeStyle: "short", - }), - ranked: match.ranked, - }; - }); - page++; + if (response.ok) { + let tmp = await response.json(); + newBatch = tmp.data.map((match: Match) => { + return { + players: match.players, + score: match.score, + date: new Date(match.date).toLocaleString("fr-FR", { + timeZone: "Europe/Paris", + dateStyle: "short", + timeStyle: "short", + }), + ranked: match.ranked, + }; + }); + page++; + } } onMount(() => { diff --git a/front/volume/src/components/Profile.svelte b/front/volume/src/components/Profile.svelte index 1ba5bd9..a1121c1 100644 --- a/front/volume/src/components/Profile.svelte +++ b/front/volume/src/components/Profile.svelte @@ -111,7 +111,7 @@ class="username" on:submit|preventDefault={handleSubmit} > - +