diff --git a/src/script/components/calling/FullscreenVideoCall.tsx b/src/script/components/calling/FullscreenVideoCall.tsx index 67290ca6ab1..15f259d4b48 100644 --- a/src/script/components/calling/FullscreenVideoCall.tsx +++ b/src/script/components/calling/FullscreenVideoCall.tsx @@ -113,6 +113,8 @@ const EMOJIS_LIST = ['👍', '🎉', '❤️', '😂', '😮', '👏', '🤔', ' const LOCAL_STORAGE_KEY_FOR_SCREEN_SHARING_CONFIRM_MODAL = 'DO_NOT_ASK_AGAIN_FOR_SCREEN_SHARING_CONFIRM_MODAL'; +const DEFAULT_VISIBLE_DOTS = 5; + const FullscreenVideoCall: React.FC = ({ call, canShareScreen, @@ -399,6 +401,51 @@ const FullscreenVideoCall: React.FC = ({ const isModerator = selfUser && roles[selfUser.id] === DefaultConversationRoleName.WIRE_ADMIN; + const [currentStart, setCurrentStart] = useState(0); + const visibleDots = DEFAULT_VISIBLE_DOTS > totalPages ? totalPages : DEFAULT_VISIBLE_DOTS; + + useEffect(() => { + const isLastInTheRange = currentPage === currentStart + visibleDots - 1; + const isLastPage = currentPage === totalPages - 1; + + if (isLastInTheRange && !isLastPage) { + return setCurrentStart(currentStart => currentStart + 1); + } + + if (currentStart + visibleDots - 1 >= totalPages && currentStart > 0) { + return setCurrentStart(currentStart => currentStart - 1); + } + }, [totalPages, setCurrentStart, currentStart, currentPage, visibleDots]); + + const handlePreviousPage = () => { + if (currentPage === 0) { + return; + } + + const previousPage = currentPage - 1; + + // previousPage !== 0 --> jest niepotrzebne prawdopodnie + if (previousPage === currentStart && previousPage !== 0) { + setCurrentStart(currentStart => currentStart - 1); + } + + changePage(previousPage, call); + }; + + const handleNextPage = () => { + if (currentPage === totalPages - 1) { + return; + } + + const nextPage = currentPage + 1; + + if (nextPage === currentStart + visibleDots - 1 && nextPage !== totalPages - 1) { + setCurrentStart(currentStart => currentStart + 1); + } + + changePage(nextPage, call); + }; + return (
@@ -450,8 +497,8 @@ const FullscreenVideoCall: React.FC = ({