-
Notifications
You must be signed in to change notification settings - Fork 735
Finalize grid mode #699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finalize grid mode #699
Changes from all commits
1442950
35ccd13
a1d4c6e
920ff1e
4c5490e
ab05ffb
fe2738d
2690dc8
0d40256
c29ad7d
0b36cbc
10dcd10
b1a0e71
a365f34
e5f8b1f
55f7c9f
4e3fbaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,14 @@ module.exports = (on, config) => { | |
| args, | ||
| }); | ||
| const page = (participants[name] = await browser.newPage()); // keep track of this participant for future use | ||
|
|
||
| // These tests were written before Grid View was implemented. This app now activates | ||
| // Grid View by default, so here we activate Presentation View before visiting the app so | ||
| // that the tests can pass. | ||
| await page.evaluateOnNewDocument(() => { | ||
| localStorage.clear(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, comment would be good. |
||
| localStorage.setItem('grid-view-active-key', false); | ||
| }); | ||
| await page.goto(config.baseUrl); | ||
| await page.type('#input-user-name', name); | ||
| await page.type('#input-room-name', roomName); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,12 @@ | ||
| import { useState, useEffect } from 'react'; | ||
| import { Participant } from 'twilio-video'; | ||
| import { useAppState } from '../../state'; | ||
| import { useAppState } from '../../../state'; | ||
|
|
||
| export function usePagination(participants: Participant[]) { | ||
| const [currentPage, setCurrentPage] = useState(1); // Pages are 1 indexed | ||
| const { maxGridParticipants } = useAppState(); | ||
|
|
||
| const totalPages = Math.ceil(participants.length / maxGridParticipants); | ||
| const isLastPage = currentPage === totalPages; | ||
| const isBeyondLastPage = currentPage > totalPages; | ||
|
|
||
| useEffect(() => { | ||
|
|
@@ -16,16 +15,10 @@ export function usePagination(participants: Participant[]) { | |
| } | ||
| }, [isBeyondLastPage, totalPages]); | ||
|
|
||
| let paginatedParticipants; | ||
|
|
||
| if (isLastPage) { | ||
| paginatedParticipants = participants.slice(-maxGridParticipants); | ||
| } else { | ||
| paginatedParticipants = participants.slice( | ||
| (currentPage - 1) * maxGridParticipants, | ||
| currentPage * maxGridParticipants | ||
| ); | ||
| } | ||
| let paginatedParticipants = participants.slice( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't make a huge difference, but I'm wondering if this hook should be moved into the GridView directory. Just so people don't think it should be used with MobileGridView pagination.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's a good idea! |
||
| (currentPage - 1) * maxGridParticipants, | ||
| currentPage * maxGridParticipants | ||
| ); | ||
|
|
||
| return { paginatedParticipants, setCurrentPage, currentPage, totalPages }; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a quick comment here about what this does would be good.