@100mslive/roomkit-react 0.2.6 → 0.2.7-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. package/dist/{HLSView-A5DVXKEU.js → HLSView-E65JZSU4.js} +2 -2
  2. package/dist/Prebuilt/common/constants.d.ts +5 -0
  3. package/dist/Prebuilt/components/AppData/useSheet.d.ts +4 -0
  4. package/dist/Prebuilt/components/Header/RoomDetailsHeader.d.ts +2 -0
  5. package/dist/Prebuilt/components/Polls/common/utils.d.ts +1 -1
  6. package/dist/Prebuilt/components/RoomDetails/Duration.d.ts +4 -0
  7. package/dist/Prebuilt/components/RoomDetails/RoomDetailsPane.d.ts +2 -0
  8. package/dist/Prebuilt/components/RoomDetails/RoomDetailsRow.d.ts +4 -0
  9. package/dist/Prebuilt/components/RoomDetails/RoomDetailsSheet.d.ts +2 -0
  10. package/dist/Prebuilt/layouts/Sheet.d.ts +2 -0
  11. package/dist/Prebuilt/provider/roomLayoutProvider/hooks/useRoomLayoutScreen.d.ts +5 -0
  12. package/dist/{chunk-KUVM2TEZ.js → chunk-DWLYDCFC.js} +1414 -1227
  13. package/dist/chunk-DWLYDCFC.js.map +7 -0
  14. package/dist/index.cjs.js +2729 -2475
  15. package/dist/index.cjs.js.map +4 -4
  16. package/dist/index.js +1 -1
  17. package/dist/meta.cjs.json +478 -45
  18. package/dist/meta.esbuild.json +486 -53
  19. package/package.json +7 -7
  20. package/src/Prebuilt/App.tsx +2 -0
  21. package/src/Prebuilt/common/constants.ts +6 -0
  22. package/src/Prebuilt/components/AppData/AppData.tsx +1 -0
  23. package/src/Prebuilt/components/AppData/useSheet.ts +33 -0
  24. package/src/Prebuilt/components/Header/Header.tsx +2 -0
  25. package/src/Prebuilt/components/Header/RoomDetailsHeader.tsx +51 -0
  26. package/src/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.tsx +18 -2
  27. package/src/Prebuilt/components/Polls/common/utils.ts +15 -9
  28. package/src/Prebuilt/components/RoomDetails/Duration.tsx +26 -0
  29. package/src/Prebuilt/components/RoomDetails/RoomDetailsPane.tsx +36 -0
  30. package/src/Prebuilt/components/RoomDetails/RoomDetailsRow.tsx +23 -0
  31. package/src/Prebuilt/components/RoomDetails/RoomDetailsSheet.tsx +45 -0
  32. package/src/Prebuilt/layouts/Sheet.tsx +14 -0
  33. package/src/Prebuilt/layouts/SidePane.tsx +4 -0
  34. package/src/Prebuilt/provider/roomLayoutProvider/hooks/useRoomLayoutScreen.ts +40 -0
  35. package/dist/chunk-KUVM2TEZ.js.map +0 -7
  36. /package/dist/{HLSView-A5DVXKEU.js.map → HLSView-E65JZSU4.js.map} +0 -0
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "prebuilt",
11
11
  "roomkit"
12
12
  ],
13
- "version": "0.2.6",
13
+ "version": "0.2.7-alpha.0",
14
14
  "author": "100ms",
15
15
  "license": "MIT",
16
16
  "repository": {
@@ -82,11 +82,11 @@
82
82
  "react": ">=17.0.2 <19.0.0"
83
83
  },
84
84
  "dependencies": {
85
- "@100mslive/hls-player": "0.2.6",
86
- "@100mslive/hms-virtual-background": "1.12.6",
87
- "@100mslive/react-icons": "0.9.6",
88
- "@100mslive/react-sdk": "0.9.6",
89
- "@100mslive/types-prebuilt": "0.12.6",
85
+ "@100mslive/hls-player": "0.2.7-alpha.0",
86
+ "@100mslive/hms-virtual-background": "1.12.7-alpha.0",
87
+ "@100mslive/react-icons": "0.9.7-alpha.0",
88
+ "@100mslive/react-sdk": "0.9.7-alpha.0",
89
+ "@100mslive/types-prebuilt": "0.12.7",
90
90
  "@emoji-mart/data": "^1.0.6",
91
91
  "@emoji-mart/react": "^1.0.1",
92
92
  "@radix-ui/react-accordion": "1.0.0",
@@ -120,5 +120,5 @@
120
120
  "uuid": "^8.3.2",
121
121
  "worker-timers": "^7.0.40"
122
122
  },
123
- "gitHead": "928f9172a44fe6c47232ab84d2c991b04cd9f707"
123
+ "gitHead": "3999106cba680bcb41ce773e10c85463da4dfeec"
124
124
  }
@@ -26,6 +26,7 @@ import { PreviewScreen } from './components/Preview/PreviewScreen';
26
26
  // @ts-ignore: No implicit Any
27
27
  import { ToastContainer } from './components/Toast/ToastContainer';
28
28
  import { VBHandler } from './components/VirtualBackground/VBHandler';
29
+ import { Sheet } from './layouts/Sheet';
29
30
  import { RoomLayoutContext, RoomLayoutProvider, useRoomLayout } from './provider/roomLayoutProvider';
30
31
  import { DialogContainerProvider } from '../context/DialogContext';
31
32
  import { Box } from '../Layout';
@@ -293,6 +294,7 @@ function AppRoutes({
293
294
  <ToastContainer />
294
295
  <Notifications />
295
296
  <MwebLandscapePrompt />
297
+ <Sheet />
296
298
  <BackSwipe />
297
299
  {!isNotificationsDisabled && <FlyingEmoji />}
298
300
  <RemoteStopScreenshare />
@@ -46,6 +46,7 @@ export const APP_DATA = {
46
46
  disableNotifications: 'disableNotifications',
47
47
  pollState: 'pollState',
48
48
  background: 'background',
49
+ sheet: 'sheet',
49
50
  };
50
51
 
51
52
  export const UI_SETTINGS = {
@@ -64,6 +65,11 @@ export const SIDE_PANE_OPTIONS = {
64
65
  STREAMING: 'STREAMING',
65
66
  POLLS: 'POLLS',
66
67
  VB: 'VB',
68
+ ROOM_DETAILS: 'ROOM_DETAILS',
69
+ };
70
+
71
+ export const SHEET_OPTIONS = {
72
+ ROOM_DETAILS: 'ROOM_DETAILS',
67
73
  };
68
74
 
69
75
  export const POLL_STATE = {
@@ -54,6 +54,7 @@ const initialAppData = {
54
54
  },
55
55
  [APP_DATA.chatDraft]: '',
56
56
  [APP_DATA.sidePane]: '',
57
+ [APP_DATA.sheet]: '',
57
58
  [APP_DATA.hlsStarted]: false,
58
59
  [APP_DATA.rtmpStarted]: false,
59
60
  [APP_DATA.recordingStarted]: false,
@@ -0,0 +1,33 @@
1
+ import { useCallback } from 'react';
2
+ import { selectAppData, useHMSActions, useHMSStore, useHMSVanillaStore } from '@100mslive/react-sdk';
3
+ import { APP_DATA } from '../../common/constants';
4
+
5
+ export const useIsSheetTypeOpen = (sheetType: string) => {
6
+ if (!sheetType) {
7
+ throw Error('Pass one of the sheet options');
8
+ }
9
+ return useHMSStore(selectAppData(APP_DATA.sheet)) === sheetType;
10
+ };
11
+
12
+ export const useSheetState = () => {
13
+ const sheet = useHMSStore(selectAppData(APP_DATA.sheet));
14
+ return sheet;
15
+ };
16
+
17
+ export const useSheetToggle = (sheetType: string) => {
18
+ const hmsActions = useHMSActions();
19
+ const vanillaStore = useHMSVanillaStore();
20
+ const toggleSheet = useCallback(() => {
21
+ const isOpen = vanillaStore.getState(selectAppData(APP_DATA.sheet)) === sheetType;
22
+ hmsActions.setAppData(APP_DATA.sheet, !isOpen ? sheetType : '');
23
+ }, [vanillaStore, hmsActions, sheetType]);
24
+ return toggleSheet;
25
+ };
26
+
27
+ export const useSheetReset = () => {
28
+ const hmsActions = useHMSActions();
29
+ const resetSheet = useCallback(() => {
30
+ hmsActions.setAppData(APP_DATA.sheet, '');
31
+ }, [hmsActions]);
32
+ return resetSheet;
33
+ };
@@ -5,6 +5,7 @@ import { config as cssConfig, Flex } from '../../..';
5
5
  // @ts-ignore: No implicit any
6
6
  import { Logo, SpeakerTag } from './HeaderComponents';
7
7
  // @ts-ignore: No implicit any
8
+ import { RoomDetailsHeader } from './RoomDetailsHeader';
8
9
  import { LiveStatus, RecordingPauseStatus, RecordingStatus, StreamActions } from './StreamActions';
9
10
  // @ts-ignore: No implicit any
10
11
  import { AudioActions, CamaraFlipActions } from './common';
@@ -20,6 +21,7 @@ export const Header = () => {
20
21
  <Flex justify="between" align="center" css={{ position: 'relative', height: '100%' }}>
21
22
  <Flex align="center" gap="2" css={{ position: 'absolute', left: '$10' }}>
22
23
  <Logo />
24
+ <RoomDetailsHeader />
23
25
  <SpeakerTag />
24
26
  {isMobile && (
25
27
  <Flex align="center" css={{ gap: '$4' }}>
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import { useMedia } from 'react-use';
3
+ import { ChevronRightIcon } from '@100mslive/react-icons';
4
+ import { Flex } from '../../../Layout';
5
+ import { Text } from '../../../Text';
6
+ import { config as cssConfig } from '../../../Theme';
7
+ import { useRoomLayoutHeader } from '../../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
8
+ import { useSheetToggle } from '../AppData/useSheet';
9
+ // @ts-ignore
10
+ import { useSidepaneToggle } from '../AppData/useSidepane';
11
+ import { SHEET_OPTIONS, SIDE_PANE_OPTIONS } from '../../common/constants';
12
+
13
+ export const RoomDetailsHeader = () => {
14
+ const { title, description } = useRoomLayoutHeader();
15
+ const isMobile = useMedia(cssConfig.media.md);
16
+ const clipLength = 80;
17
+ const toggleDetailsPane = useSidepaneToggle(SIDE_PANE_OPTIONS.ROOM_DETAILS);
18
+ const toggleDetailsSheet = useSheetToggle(SHEET_OPTIONS.ROOM_DETAILS);
19
+
20
+ if ((!title && !description) || (isMobile && !title)) {
21
+ return null;
22
+ }
23
+
24
+ return (
25
+ <Flex direction={isMobile ? 'row' : 'column'} css={{ ml: '$8', alignItems: isMobile ? 'center' : 'start' }}>
26
+ <Text variant="sm" css={{ c: '$on_surface_high', fontWeight: '$semiBold' }}>
27
+ {title}
28
+ </Text>
29
+ {!isMobile && (
30
+ <Flex align="end" css={{ color: '$on_surface_high' }}>
31
+ <Text variant="xs" css={{ c: '$on_surface_medium' }}>
32
+ {description.slice(0, clipLength)}
33
+ </Text>
34
+ {description.length > clipLength ? (
35
+ <span
36
+ style={{ fontWeight: '600', fontSize: '12px', cursor: 'pointer', lineHeight: '1rem' }}
37
+ onClick={toggleDetailsPane}
38
+ >
39
+ &nbsp;...more
40
+ </span>
41
+ ) : null}
42
+ </Flex>
43
+ )}
44
+ {isMobile && description ? (
45
+ <Flex css={{ color: '$on_surface_medium' }}>
46
+ <ChevronRightIcon height={16} width={16} onClick={toggleDetailsSheet} />
47
+ </Flex>
48
+ ) : null}
49
+ </Flex>
50
+ );
51
+ };
@@ -17,6 +17,7 @@ import {
17
17
  HamburgerMenuIcon,
18
18
  HandIcon,
19
19
  HandRaiseSlashedIcon,
20
+ InfoIcon,
20
21
  PeopleIcon,
21
22
  QuizActiveIcon,
22
23
  QuizIcon,
@@ -41,6 +42,8 @@ import { ActionTile } from '../ActionTile';
41
42
  import { ChangeNameModal } from '../ChangeNameModal';
42
43
  // @ts-ignore: No implicit any
43
44
  import { MuteAllModal } from '../MuteAllModal';
45
+ import { useRoomLayoutHeader } from '../../../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
46
+ import { useSheetToggle } from '../../AppData/useSheet';
44
47
  // @ts-ignore: No implicit any
45
48
  import { usePollViewToggle, useSidepaneToggle } from '../../AppData/useSidepane';
46
49
  // @ts-ignore: No implicit Any
@@ -53,7 +56,7 @@ import { useUnreadPollQuizPresent } from '../../hooks/useUnreadPollQuizPresent';
53
56
  // @ts-ignore: No implicit any
54
57
  import { getFormattedCount } from '../../../common/utils';
55
58
  // @ts-ignore: No implicit any
56
- import { SIDE_PANE_OPTIONS } from '../../../common/constants';
59
+ import { SHEET_OPTIONS, SIDE_PANE_OPTIONS } from '../../../common/constants';
57
60
 
58
61
  const MODALS = {
59
62
  CHANGE_NAME: 'changeName',
@@ -93,7 +96,8 @@ export const MwebOptions = ({
93
96
  const { toggleAudio, toggleVideo } = useAVToggle();
94
97
  const noAVPermissions = !(toggleAudio || toggleVideo);
95
98
  const { unreadPollQuiz, setUnreadPollQuiz } = useUnreadPollQuizPresent();
96
- // const toggleVB = useSidepaneToggle(SIDE_PANE_OPTIONS.VB);
99
+ const { title, description } = useRoomLayoutHeader();
100
+ const toggleDetailsSheet = useSheetToggle(SHEET_OPTIONS.ROOM_DETAILS);
97
101
 
98
102
  useDropdownList({ open: openModals.size > 0 || openOptionsSheet || openSettingsSheet, name: 'MoreSettings' });
99
103
 
@@ -291,6 +295,18 @@ export const MwebOptions = ({
291
295
  </ActionTile.Title>
292
296
  </ActionTile.Root>
293
297
  ) : null}
298
+
299
+ {title || description ? (
300
+ <ActionTile.Root
301
+ onClick={() => {
302
+ setOpenOptionsSheet(false);
303
+ toggleDetailsSheet();
304
+ }}
305
+ >
306
+ <InfoIcon />
307
+ <ActionTile.Title>About Session</ActionTile.Title>
308
+ </ActionTile.Root>
309
+ ) : null}
294
310
  </Box>
295
311
  </Sheet.Content>
296
312
  </Sheet.Root>
@@ -1,16 +1,22 @@
1
- export const getFormattedTime = (milliseconds: number | undefined) => {
1
+ export const getFormattedTime = (milliseconds: number | undefined, precise = true) => {
2
2
  if (!milliseconds) return '-';
3
3
 
4
4
  const totalSeconds = milliseconds / 1000;
5
- const minutes = Math.floor(totalSeconds / 60);
6
- const seconds = totalSeconds % 60;
5
+ const hours = Math.floor(totalSeconds / 3600);
6
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
7
+ const seconds = precise ? totalSeconds % 60 : Math.floor(totalSeconds % 60);
7
8
 
8
- let formattedSeconds = '';
9
- if (Number.isInteger(seconds) || minutes) {
10
- formattedSeconds = seconds.toFixed(0);
11
- } else {
12
- formattedSeconds = seconds.toFixed(1);
9
+ let formattedTime = '';
10
+ if (hours) {
11
+ formattedTime += `${hours}h `;
13
12
  }
13
+ if (minutes || hours) {
14
+ formattedTime += `${minutes}m `;
15
+ }
16
+ if (!precise && (hours || minutes)) {
17
+ return formattedTime;
18
+ }
19
+ formattedTime += `${seconds}s`;
14
20
 
15
- return `${minutes ? `${minutes}m ` : ''}${formattedSeconds}s`;
21
+ return formattedTime;
16
22
  };
@@ -0,0 +1,26 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Flex } from '../../../Layout';
3
+ import { Text } from '../../../Text';
4
+ import { getFormattedTime } from '../Polls/common/utils';
5
+
6
+ export const Duration = ({ timestamp }: { timestamp: Date }) => {
7
+ const [elapsedTime, setElapsedTime] = useState(getFormattedTime(Date.now() - timestamp.getTime(), false));
8
+
9
+ useEffect(() => {
10
+ const timerAdded = setInterval(() => {
11
+ setElapsedTime(getFormattedTime(Date.now() - timestamp.getTime(), false));
12
+ }, 1000);
13
+
14
+ return () => {
15
+ clearInterval(timerAdded);
16
+ };
17
+ }, [timestamp]);
18
+
19
+ return (
20
+ <Flex css={{ color: '$on_surface_medium' }}>
21
+ <Text variant="xs" css={{ color: 'inherit' }}>
22
+ Started {elapsedTime} ago
23
+ </Text>
24
+ </Flex>
25
+ );
26
+ };
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { CrossIcon } from '@100mslive/react-icons';
3
+ import { Box, Flex } from '../../../Layout';
4
+ import { Text } from '../../../Text';
5
+ import { RoomDetailsRow } from './RoomDetailsRow';
6
+ import { useRoomLayoutHeader } from '../../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
7
+ // @ts-ignore
8
+ import { useSidepaneToggle } from '../AppData/useSidepane';
9
+ import { SIDE_PANE_OPTIONS } from '../../common/constants';
10
+
11
+ export const RoomDetailsPane = () => {
12
+ const { title, description, details } = useRoomLayoutHeader();
13
+ const toggleDetailsPane = useSidepaneToggle(SIDE_PANE_OPTIONS.ROOM_DETAILS);
14
+ return (
15
+ <Box css={{ flex: '1 1 0' }}>
16
+ <Flex justify="between" align="center" css={{ w: '100%' }}>
17
+ <Text variant="h6">{title}</Text>
18
+ <Flex
19
+ onClick={toggleDetailsPane}
20
+ css={{ color: '$on_surface_high', cursor: 'pointer', '&:hover': { opacity: '0.8' } }}
21
+ >
22
+ <CrossIcon />
23
+ </Flex>
24
+ </Flex>
25
+
26
+ <RoomDetailsRow details={details} />
27
+
28
+ <Box css={{ mt: '$10' }}>
29
+ <Text css={{ color: '$on_surface_high', fontWeight: '$semiBold' }}>Description</Text>
30
+ <Text variant="sm" css={{ c: '$on_surface_medium' }}>
31
+ {description}
32
+ </Text>
33
+ </Box>
34
+ </Box>
35
+ );
36
+ };
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { Box, Flex } from '../../../Layout';
3
+ import { Text } from '../../../Text';
4
+ import { Duration } from './Duration';
5
+
6
+ export const RoomDetailsRow = ({ details }: { details: (string | Date)[] }) => {
7
+ return (
8
+ <Flex align="center" css={{ w: '100%' }}>
9
+ {details.map((detail, index) => (
10
+ <React.Fragment key={detail.toString()}>
11
+ {index > 0 && <Box css={{ h: '$2', w: '$2', r: '$round', bg: '$on_surface_medium', m: '0 $2' }} />}
12
+ {typeof detail !== 'string' ? (
13
+ <Duration timestamp={detail} />
14
+ ) : (
15
+ <Text variant="xs" css={{ c: '$on_surface_medium' }}>
16
+ {detail}
17
+ </Text>
18
+ )}
19
+ </React.Fragment>
20
+ ))}
21
+ </Flex>
22
+ );
23
+ };
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import { CrossIcon } from '@100mslive/react-icons';
3
+ import { Box, Flex } from '../../../Layout';
4
+ import { Sheet } from '../../../Sheet';
5
+ import { Text } from '../../../Text';
6
+ // @ts-ignore
7
+ import { Logo } from '../Header/HeaderComponents';
8
+ import { RoomDetailsRow } from './RoomDetailsRow';
9
+ import { useRoomLayoutHeader } from '../../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
10
+ import { useIsSheetTypeOpen, useSheetToggle } from '../AppData/useSheet';
11
+ import { SHEET_OPTIONS } from '../../common/constants';
12
+
13
+ export const RoomDetailsSheet = () => {
14
+ const { title, description, details } = useRoomLayoutHeader();
15
+ const toggleSheet = useSheetToggle(SHEET_OPTIONS.ROOM_DETAILS);
16
+ const showRoomDetailsSheet = useIsSheetTypeOpen(SHEET_OPTIONS.ROOM_DETAILS);
17
+ return (
18
+ <Sheet.Root open={showRoomDetailsSheet} onOpenChange={toggleSheet}>
19
+ <Sheet.Content css={{ py: '$8', pb: '$12' }}>
20
+ <Flex
21
+ justify="between"
22
+ align="center"
23
+ css={{ w: '100%', borderBottom: '1px solid $border_bright', pb: '$4', mb: '$4', px: '$8' }}
24
+ >
25
+ <Text css={{ fontWeight: '$semiBold', color: '$on_surface_high' }}>Description</Text>
26
+ <Sheet.Close css={{ color: '$on_surface_high' }}>
27
+ <CrossIcon />
28
+ </Sheet.Close>
29
+ </Flex>
30
+ <Flex align="center" css={{ w: '100%', gap: '$4', pb: '$8', px: '$8' }}>
31
+ <Logo />
32
+ <Box>
33
+ <Text variant="sm" css={{ c: '$on_secondary_high', fontWeight: '$semiBold' }}>
34
+ {title}
35
+ </Text>
36
+ <RoomDetailsRow details={details} />
37
+ </Box>
38
+ </Flex>
39
+ <Text variant="sm" css={{ color: '$on_surface_medium', px: '$8' }}>
40
+ {description}
41
+ </Text>
42
+ </Sheet.Content>
43
+ </Sheet.Root>
44
+ );
45
+ };
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { selectAppData, useHMSStore } from '@100mslive/react-sdk';
3
+ import { RoomDetailsSheet } from '../components/RoomDetails/RoomDetailsSheet';
4
+ import { Box } from '../../Layout';
5
+ import { APP_DATA, SHEET_OPTIONS } from '../common/constants';
6
+
7
+ export const Sheet = () => {
8
+ const sheet = useHMSStore(selectAppData(APP_DATA.sheet));
9
+ let ViewComponent;
10
+ if (sheet === SHEET_OPTIONS.ROOM_DETAILS) {
11
+ ViewComponent = <RoomDetailsSheet />;
12
+ }
13
+ return <Box>{ViewComponent}</Box>;
14
+ };
@@ -2,6 +2,7 @@ import React, { useEffect } from 'react';
2
2
  import { useMedia } from 'react-use';
3
3
  import { selectAppData, selectVideoTrackByPeerID, useHMSStore } from '@100mslive/react-sdk';
4
4
  import { Polls } from '../components/Polls/Polls';
5
+ import { RoomDetailsPane } from '../components/RoomDetails/RoomDetailsPane';
5
6
  import { LayoutMode } from '../components/Settings/LayoutSettings';
6
7
  import { SidePaneTabs } from '../components/SidePaneTabs';
7
8
  import { TileCustomisationProps } from '../components/VideoLayouts/GridLayout';
@@ -52,6 +53,9 @@ const SidePane = ({
52
53
  if (sidepane === SIDE_PANE_OPTIONS.VB) {
53
54
  ViewComponent = <VBPicker backgroundMedia={backgroundMedia} />;
54
55
  }
56
+ if (sidepane === SIDE_PANE_OPTIONS.ROOM_DETAILS) {
57
+ ViewComponent = <RoomDetailsPane />;
58
+ }
55
59
 
56
60
  useEffect(() => {
57
61
  return () => {
@@ -1,3 +1,4 @@
1
+ import { useMemo } from 'react';
1
2
  import {
2
3
  ConferencingScreen,
3
4
  DefaultConferencingScreen_Elements,
@@ -7,7 +8,16 @@ import {
7
8
  PreviewScreen,
8
9
  Screens,
9
10
  } from '@100mslive/types-prebuilt';
11
+ import {
12
+ selectHLSState,
13
+ selectPeerCount,
14
+ selectRoomStartTime,
15
+ useHMSStore,
16
+ useRecordingStreaming,
17
+ } from '@100mslive/react-sdk';
10
18
  import { useRoomLayout } from '..';
19
+ // @ts-ignore
20
+ import { getFormattedCount } from '../../../common/utils';
11
21
 
12
22
  export type useRoomLayoutScreenProps = {
13
23
  screen: keyof Screens;
@@ -69,3 +79,33 @@ export function useRoomLayoutLeaveScreen() {
69
79
  isLeaveScreenEnabled,
70
80
  };
71
81
  }
82
+
83
+ export function useRoomLayoutHeader() {
84
+ const { elements } = useRoomLayoutConferencingScreen();
85
+ // return elements.header;
86
+ const { isRecordingOn } = useRecordingStreaming();
87
+ const peerCount = useHMSStore(selectPeerCount);
88
+ const sessionStartedAt = useHMSStore(selectRoomStartTime);
89
+ const hlsState = useHMSStore(selectHLSState);
90
+
91
+ // People watching, start timestamp, recording status
92
+ const details = useMemo(() => {
93
+ const details = [];
94
+ if (hlsState?.variants[0]?.['startedAt']) {
95
+ details.push(`${getFormattedCount(peerCount)} watching`);
96
+ details.push(hlsState.variants[0]['startedAt']);
97
+ } else if (sessionStartedAt) {
98
+ details.push(sessionStartedAt);
99
+ }
100
+ if (isRecordingOn) {
101
+ details.push('Recording');
102
+ }
103
+ return details;
104
+ }, [hlsState?.variants, isRecordingOn, peerCount, sessionStartedAt]);
105
+
106
+ return {
107
+ title: elements.header?.title || '',
108
+ description: elements.header?.description || '',
109
+ details,
110
+ };
111
+ }