Skip to content
This repository has been archived by the owner on Dec 24, 2024. It is now read-only.

Commit

Permalink
feat(multistream): add default view
Browse files Browse the repository at this point in the history
  • Loading branch information
Entrivax committed Nov 10, 2024
1 parent 1256e97 commit 51dc2da
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/pages/playlists/multistream/[playlistId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,29 @@ const PlaylistMultistream = (props: { playlistId: string }) => {

_streamers[vod.edges.channel.id].vods.push(vod)
}

// COmpute default view
const streamersCount = Object.keys(_streamers).length;
let rows = 1;
if (streamersCount > 3) {
rows = 2;
}
let columns = Math.ceil(streamersCount / rows);
setGridWidth(columns);
setGridHeight(rows);
let i = 0;
let defaultViewState: Record<string, { tileX: number; tileY: number; tileWidth: number; tileHeight: number } | null> = {}
for (let streamerId in _streamers) {
defaultViewState[streamerId] = {
tileX: i % columns,
tileY: Math.floor(i / columns),
tileWidth: 1,
tileHeight: 1,
}
i++;
}
setStreamerViewState(defaultViewState);

setStartDateMs(_startDateMs)
setEndDateMs(_endDateMs)
setStreamers(_streamers)
Expand Down

0 comments on commit 51dc2da

Please sign in to comment.