From 32fef0f3ccaa3ceadcb444ceb11623a26f1745ad Mon Sep 17 00:00:00 2001 From: Ashurov Georgy Date: Sun, 15 Dec 2024 04:32:11 +0300 Subject: [PATCH] Add showing avatars in users list --- public/modules/Serializer.ts | 11 +++++++++++ public/store/RoomPageStore.ts | 8 ++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/public/modules/Serializer.ts b/public/modules/Serializer.ts index 8f5dcfa..3e1f512 100644 --- a/public/modules/Serializer.ts +++ b/public/modules/Serializer.ts @@ -157,3 +157,14 @@ export const serializeSavedMovies = (savedMovies: any) => { return serializeSavedMovie(savedMovie); }); }; + +export const serializeUsersList = (users: any) => { + return users.map((user: any) => { + return { + id: user.id, + username: user.username, + email: user.email, + avatar: HOST + user.avatar_url, + }; + }); +}; diff --git a/public/store/RoomPageStore.ts b/public/store/RoomPageStore.ts index bd2dd9c..47d630c 100644 --- a/public/store/RoomPageStore.ts +++ b/public/store/RoomPageStore.ts @@ -8,7 +8,11 @@ import { User } from 'types/user'; import { apiClient } from 'modules/ApiClient'; import { router } from 'modules/Router'; import { Emitter } from 'modules/Emmiter'; -import { serializeRoom, serializeMovieDetailed } from 'modules/Serializer'; +import { + serializeRoom, + serializeMovieDetailed, + serializeUsersList, +} from 'modules/Serializer'; const roomPage = new RoomPage(); @@ -145,7 +149,7 @@ class RoomPageStore { this.setState(serializeRoom(messageData)); roomPage.render(); } else if (Array.isArray(messageData)) { - roomPage.renderUsersList(messageData); + roomPage.renderUsersList(serializeUsersList(messageData)); } else if (messageData.timeCode) { if (messageData.timeCode - roomPage.getCurrentVideoTime() > 2) { roomPage.setVideoTime(messageData.timeCode);