From 3c3bff1161fa9ddd8925344534d5830eab1df895 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 14 Jan 2026 10:38:17 +0000
Subject: [PATCH 1/4] Initial plan
From cee05b84411890f57d80cc739abc8e7c79992c38 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 14 Jan 2026 10:45:53 +0000
Subject: [PATCH 2/4] perf: optimize React component rendering with memoization
Co-authored-by: underscorekadji <3449713+underscorekadji@users.noreply.github.com>
---
src/app/room/components/RoomLayout.tsx | 35 +++++++++++++++-----------
src/app/room/components/Wheel.tsx | 24 ++++++++++++------
2 files changed, 37 insertions(+), 22 deletions(-)
diff --git a/src/app/room/components/RoomLayout.tsx b/src/app/room/components/RoomLayout.tsx
index 51f2563..4a43f7d 100644
--- a/src/app/room/components/RoomLayout.tsx
+++ b/src/app/room/components/RoomLayout.tsx
@@ -1,6 +1,6 @@
'use client'
-import { useState, useEffect } from 'react'
+import { useState, useEffect, useMemo } from 'react'
import {
ParticipantRoleEnum,
ParticipantStatusEnum,
@@ -323,6 +323,26 @@ export function RoomLayout({ roomId, initialData }: RoomLayoutProps) {
}
}
+ const currentPresenter = useMemo(
+ () =>
+ roomData?.currentPresenterId
+ ? roomData.participants.find(p => p.id === roomData.currentPresenterId)
+ : null,
+ [roomData?.currentPresenterId, roomData?.participants]
+ )
+
+ const lastWinner = useMemo(
+ () =>
+ lastWinnerState ||
+ (currentPresenter
+ ? {
+ id: currentPresenter.id,
+ name: currentPresenter.name,
+ }
+ : null),
+ [lastWinnerState, currentPresenter]
+ )
+
if (!roomData) {
return (
p.id === roomData.currentPresenterId)
- : null
-
- const lastWinner =
- lastWinnerState ||
- (currentPresenter
- ? {
- id: currentPresenter.id,
- name: currentPresenter.name,
- }
- : null)
-
return (
diff --git a/src/app/room/components/Wheel.tsx b/src/app/room/components/Wheel.tsx
index ffc6590..a967f07 100644
--- a/src/app/room/components/Wheel.tsx
+++ b/src/app/room/components/Wheel.tsx
@@ -101,10 +101,18 @@ export const Wheel: React.FC
= ({
lastWinner,
className = '',
}) => {
- // Ensure participants is array and get eligible ones
- const safeParticipants = Array.isArray(participants) ? participants : []
- const eligibleParticipants = safeParticipants.filter(
- p => p.status === ParticipantStatusEnum.QUEUED || p.status === ParticipantStatusEnum.ACTIVE
+ // Ensure participants is array and get eligible ones - memoized to avoid recalculation
+ const safeParticipants = useMemo(
+ () => (Array.isArray(participants) ? participants : []),
+ [participants]
+ )
+
+ const eligibleParticipants = useMemo(
+ () =>
+ safeParticipants.filter(
+ p => p.status === ParticipantStatusEnum.QUEUED || p.status === ParticipantStatusEnum.ACTIVE
+ ),
+ [safeParticipants]
)
// Convert participants to wheel items
@@ -183,8 +191,8 @@ export const Wheel: React.FC = ({
}
}
- // Render sectors
- const renderSectors = (): React.ReactElement[] => {
+ // Render sectors - memoized to avoid recalculation on every render
+ const renderedSectors = useMemo((): React.ReactElement[] => {
if (sectors.length === 0) {
return [
= ({
)
})
- }
+ }, [sectors, anglePerItem])
// Обработчик спина
const spin = (): void => {
@@ -297,7 +305,7 @@ export const Wheel: React.FC = ({
{/* Wheel Container */}