@selfcommunity/react-ui 0.8.0-live.46 → 0.8.0-live.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,7 @@ const react_intl_1 = require("react-intl");
13
13
  const LiveStream_1 = require("../../constants/LiveStream");
14
14
  const constants_1 = require("./constants");
15
15
  const UploadEventCover_1 = tslib_1.__importDefault(require("../EventForm/UploadEventCover"));
16
+ const liveStream_1 = require("../../utils/liveStream");
16
17
  const classes = {
17
18
  root: `${constants_1.PREFIX}-root`,
18
19
  form: `${constants_1.PREFIX}-form`,
@@ -124,8 +125,9 @@ function LiveStreamForm(inProps) {
124
125
  }
125
126
  formData.append('title', field.title);
126
127
  formData.append('description', field.description);
128
+ // TODO: for testing
127
129
  setTimeout(() => {
128
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess({});
130
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess({ roomName: (0, liveStream_1.generateRoomId)() });
129
131
  setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
130
132
  }, 1000);
131
133
  /*
@@ -1,6 +1,9 @@
1
1
  import { BoxProps } from '@mui/material';
2
2
  import { SCLiveStreamType } from '@selfcommunity/types';
3
+ import { LocalUserChoices } from '@livekit/components-react';
3
4
  import React from 'react';
5
+ import { ConnectionDetails } from './types';
6
+ import { LiveStreamVideoConferenceProps } from './LiveStreamVideoConference';
4
7
  import '@livekit/components-styles';
5
8
  export interface LiveStreamRoomProps extends BoxProps {
6
9
  /**
@@ -33,6 +36,21 @@ export interface LiveStreamRoomProps extends BoxProps {
33
36
  * Show description of livestream in prejoin
34
37
  */
35
38
  showPrejoinDescription?: boolean;
39
+ /**
40
+ * ConnectionDetails Object
41
+ * @default null
42
+ */
43
+ presetConnectionDetails?: ConnectionDetails;
44
+ /**
45
+ * LocalUserChoices Object
46
+ * @default null
47
+ */
48
+ presetPreJoinChoices?: LocalUserChoices;
49
+ /**
50
+ * Props to spread to LiveStreamVideoConference Component
51
+ * @default {}
52
+ */
53
+ LiveStreamVideoConferenceComponentProps?: LiveStreamVideoConferenceProps;
36
54
  /**
37
55
  * Any other properties
38
56
  */
@@ -21,6 +21,8 @@ const classes = {
21
21
  description: `${constants_1.PREFIX}-description`,
22
22
  startPrejoinContent: `${constants_1.PREFIX}-start-prejoin-content`,
23
23
  preJoin: `${constants_1.PREFIX}-prejoin`,
24
+ preJoinLoading: `${constants_1.PREFIX}-prejoin-loading`,
25
+ prejoinLoader: `${constants_1.PREFIX}-prejoin-loader`,
24
26
  endPrejoinContent: `${constants_1.PREFIX}-end-prejoin-content`,
25
27
  conference: `${constants_1.PREFIX}-conference`,
26
28
  error: `${constants_1.PREFIX}-error`
@@ -61,14 +63,14 @@ function LiveStreamRoom(inProps) {
61
63
  props: inProps,
62
64
  name: constants_1.PREFIX
63
65
  });
64
- const { className, liveStream = null, showPrejoinTitle = true, showPrejoinDescription = false, startPrejoinContent, endPrejoinContent, connectionDetailsEndpoint } = props, rest = tslib_1.__rest(props, ["className", "liveStream", "showPrejoinTitle", "showPrejoinDescription", "startPrejoinContent", "endPrejoinContent", "connectionDetailsEndpoint"]);
66
+ const { className, liveStream = null, showPrejoinTitle = true, showPrejoinDescription = false, startPrejoinContent, endPrejoinContent, connectionDetailsEndpoint, presetConnectionDetails, presetPreJoinChoices, LiveStreamVideoConferenceComponentProps = {} } = props, rest = tslib_1.__rest(props, ["className", "liveStream", "showPrejoinTitle", "showPrejoinDescription", "startPrejoinContent", "endPrejoinContent", "connectionDetailsEndpoint", "presetConnectionDetails", "presetPreJoinChoices", "LiveStreamVideoConferenceComponentProps"]);
65
67
  // CONTEXT
66
68
  const scUserContext = (0, react_core_1.useSCUser)();
67
69
  const { preferences, features } = (0, react_core_1.useSCPreferences)();
68
70
  // INTL
69
71
  const intl = (0, react_intl_1.useIntl)();
70
72
  // STATE
71
- const [preJoinChoices, setPreJoinChoices] = (0, react_1.useState)(undefined);
73
+ const [preJoinChoices, setPreJoinChoices] = (0, react_1.useState)(presetPreJoinChoices);
72
74
  const [loading, setLoading] = (0, react_1.useState)(false);
73
75
  const preJoinDefaults = (0, react_1.useMemo)(() => {
74
76
  var _a;
@@ -78,7 +80,7 @@ function LiveStreamRoom(inProps) {
78
80
  audioEnabled: true
79
81
  };
80
82
  }, [scUserContext.user]);
81
- const [connectionDetails, setConnectionDetails] = (0, react_1.useState)(undefined);
83
+ const [connectionDetails, setConnectionDetails] = (0, react_1.useState)(presetConnectionDetails);
82
84
  const liveStreamEnabled = true;
83
85
  /* const liveStreamEnabled = useMemo(
84
86
  () =>
@@ -90,6 +92,17 @@ function LiveStreamRoom(inProps) {
90
92
  [preferences, features]
91
93
  ); */
92
94
  const canCreateLiveStream = (0, react_1.useMemo)(() => true /* scUserContext?.user?.permission?.create_livestream */, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
95
+ const toggleAttrDisabledPrejoinActions = (0, react_1.useCallback)((disabled) => {
96
+ const container = document.querySelector('.lk-prejoin');
97
+ if (container) {
98
+ const buttons = container.querySelectorAll('button.lk-button');
99
+ buttons.forEach((button) => {
100
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
101
+ // @ts-ignore
102
+ button.disabled = disabled;
103
+ });
104
+ }
105
+ }, []);
93
106
  // HANDLERS
94
107
  /**
95
108
  * Handle PreJoin Submit
@@ -99,16 +112,18 @@ function LiveStreamRoom(inProps) {
99
112
  // eslint-disable-next-line no-constant-condition
100
113
  if ((liveStream || true) && connectionDetailsEndpoint) {
101
114
  setLoading(true);
115
+ toggleAttrDisabledPrejoinActions(true);
102
116
  setPreJoinChoices(values);
103
117
  const url = new URL(connectionDetailsEndpoint, window.location.origin);
104
- url.searchParams.append('roomName', (0, liveStream_1.generateRoomId)());
118
+ url.searchParams.append('roomName', liveStream.roomName || (0, liveStream_1.generateRoomId)());
105
119
  url.searchParams.append('participantName', (_b = scUserContext.user) === null || _b === void 0 ? void 0 : _b.username);
106
- // if (liveStream.region) {
107
- // url.searchParams.append('region', liveStream.region);
108
- // }
120
+ /* if (liveStream && liveStream.region) {
121
+ url.searchParams.append('region', liveStream.region);
122
+ } */
109
123
  const connectionDetailsResp = yield fetch(url.toString());
110
124
  const connectionDetailsData = yield connectionDetailsResp.json();
111
125
  setConnectionDetails(connectionDetailsData);
126
+ toggleAttrDisabledPrejoinActions(false);
112
127
  setLoading(false);
113
128
  }
114
129
  }), [scUserContext.user, connectionDetailsEndpoint, setPreJoinChoices, setConnectionDetails]);
@@ -125,6 +140,6 @@ function LiveStreamRoom(inProps) {
125
140
  /**
126
141
  * Renders root object
127
142
  */
128
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.content, "data-lk-theme": "default" }, { children: connectionDetails === undefined || preJoinChoices === undefined ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [startPrejoinContent && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.startPrejoinContent }, { children: startPrejoinContent })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.title) && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.title }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.title })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.description) && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.description }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.description })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.preJoin }, { children: (0, jsx_runtime_1.jsx)(components_react_1.PreJoin, { persistUserChoices: true, defaults: preJoinDefaults, onSubmit: handlePreJoinSubmit, onError: handlePreJoinError }) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.endPrejoinContent }, { children: endPrejoinContent }))] })) : ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.conference }, { children: (0, jsx_runtime_1.jsx)(LiveStreamVideoConference_1.default, { connectionDetails: connectionDetails, userChoices: preJoinChoices, options: { codec: props.codec, hq: props.hq } }) }))) })) })));
143
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.content, "data-lk-theme": "default" }, { children: connectionDetails === undefined || preJoinChoices === undefined ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [startPrejoinContent && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.startPrejoinContent }, { children: startPrejoinContent })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.title) && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.title }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.title })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.description) && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.description }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.description })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: (0, classnames_1.default)(classes.preJoin, { [classes.preJoinLoading]: loading }) }, { children: [(0, jsx_runtime_1.jsx)(components_react_1.PreJoin, { persistUserChoices: true, defaults: preJoinDefaults, onSubmit: handlePreJoinSubmit, onError: handlePreJoinError }), loading && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.prejoinLoader }, { children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, {}) })))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.endPrejoinContent }, { children: endPrejoinContent }))] })) : ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.conference }, { children: (0, jsx_runtime_1.jsx)(LiveStreamVideoConference_1.default, Object.assign({ connectionDetails: connectionDetails, userChoices: preJoinChoices, options: { codec: props.codec, hq: props.hq } }, LiveStreamVideoConferenceComponentProps)) }))) })) })));
129
144
  }
130
145
  exports.default = LiveStreamRoom;
@@ -2,6 +2,7 @@ import { BoxProps } from '@mui/material';
2
2
  import { SCLiveStreamType } from '@selfcommunity/types/src/index';
3
3
  import { LiveKitRoomProps, LocalUserChoices } from '@livekit/components-react';
4
4
  import { VideoCodec } from 'livekit-client';
5
+ import React from 'react';
5
6
  import { ConnectionDetails } from '../types';
6
7
  export interface LiveStreamVideoConferenceProps extends BoxProps {
7
8
  /**
@@ -42,6 +43,14 @@ export interface LiveStreamVideoConferenceProps extends BoxProps {
42
43
  * @default {}
43
44
  */
44
45
  LiveKitRoomComponentsProps?: LiveKitRoomProps;
46
+ /**
47
+ * Element to be inserted before end conference content
48
+ */
49
+ startConferenceEndContent?: React.ReactNode | null;
50
+ /**
51
+ * Element to be inserted after end conference content
52
+ */
53
+ endConferenceEndContent?: React.ReactNode | null;
45
54
  /**
46
55
  * Any other properties
47
56
  */
@@ -13,10 +13,13 @@ const react_1 = require("react");
13
13
  const RecordingIndicator_1 = tslib_1.__importDefault(require("./RecordingIndicator"));
14
14
  const components_core_1 = require("@livekit/components-core");
15
15
  const constants_2 = require("../constants");
16
+ const react_intl_1 = require("react-intl");
16
17
  const classes = {
17
18
  root: `${constants_1.PREFIX}-root`,
18
19
  title: `${constants_1.PREFIX}-title`,
19
20
  content: `${constants_1.PREFIX}-content`,
21
+ endConferenceWrap: `${constants_1.PREFIX}-end-conference-wrap`,
22
+ btnBackHome: `${constants_1.PREFIX}-btn-back-home`,
20
23
  actions: `${constants_1.PREFIX}-actions`,
21
24
  error: `${constants_1.PREFIX}-error`
22
25
  };
@@ -51,9 +54,10 @@ function LiveStreamVideoConference(inProps) {
51
54
  });
52
55
  const { className, liveStream = null, handleOnLeaveRoom, userChoices = components_core_1.defaultUserChoices, connectionDetails = {}, LiveKitRoomComponentsProps = {
53
56
  /* simulateParticipants: true */
54
- }, options = constants_2.defaultVideoOptions } = props, rest = tslib_1.__rest(props, ["className", "liveStream", "handleOnLeaveRoom", "userChoices", "connectionDetails", "LiveKitRoomComponentsProps", "options"]);
57
+ }, startConferenceEndContent, endConferenceEndContent, options = constants_2.defaultVideoOptions } = props, rest = tslib_1.__rest(props, ["className", "liveStream", "handleOnLeaveRoom", "userChoices", "connectionDetails", "LiveKitRoomComponentsProps", "startConferenceEndContent", "endConferenceEndContent", "options"]);
55
58
  // CONTEXT
56
59
  const scUserContext = (0, react_core_1.useSCUser)();
60
+ const scRoutingContext = (0, react_core_1.useSCRouting)();
57
61
  const { preferences, features } = (0, react_core_1.useSCPreferences)();
58
62
  // Passphrase
59
63
  // const e2eePassphrase = typeof window !== 'undefined' && decodePassphrase(location.hash.substring(1));
@@ -174,6 +178,6 @@ function LiveStreamVideoConference(inProps) {
174
178
  /**
175
179
  * Renders root object
176
180
  */
177
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: liveActive && !error ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(components_react_1.LiveKitRoom, Object.assign({ connect: Boolean(e2eeSetupComplete && liveActive), token: connectionDetails['participantToken'], serverUrl: connectionDetails['serverUrl'], connectOptions: connectOptions, video: userChoices.videoEnabled, audio: userChoices.audioEnabled, onDisconnected: handleOnLeave, onEncryptionError: handleEncryptionError, onError: handleError }, LiveKitRoomComponentsProps, { children: [(0, jsx_runtime_1.jsx)(components_react_1.VideoConference, { chatMessageFormatter: components_react_1.formatChatMessageLinks }), (0, jsx_runtime_1.jsx)(RecordingIndicator_1.default, {}), (0, jsx_runtime_1.jsx)(components_react_1.ConnectionState, {})] })) })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: error ? error : liveActive === false ? (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: "Grazie!" }) : (0, jsx_runtime_1.jsx)(material_1.CircularProgress, {}) })) })));
181
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: liveActive && !error ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(components_react_1.LiveKitRoom, Object.assign({ connect: Boolean(e2eeSetupComplete && liveActive), token: connectionDetails['participantToken'], serverUrl: connectionDetails['serverUrl'], connectOptions: connectOptions, video: userChoices.videoEnabled, audio: userChoices.audioEnabled, onDisconnected: handleOnLeave, onEncryptionError: handleEncryptionError, onError: handleError }, LiveKitRoomComponentsProps, { children: [(0, jsx_runtime_1.jsx)(components_react_1.VideoConference, { chatMessageFormatter: components_react_1.formatChatMessageLinks }), (0, jsx_runtime_1.jsx)(RecordingIndicator_1.default, {}), (0, jsx_runtime_1.jsx)(components_react_1.ConnectionState, {})] })) })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: error ? (error) : liveActive === false ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.endConferenceWrap }, { children: [startConferenceEndContent, (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.liveStreamRoom.conference.end", defaultMessage: "ui.liveStreamRoom.conference.end" }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ color: "secondary", component: react_core_1.Link, to: '/', className: classes.btnBackHome }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.liveStreamRoom.button.backHome", defaultMessage: "ui.liveStreamRoom.button.backHome" }) })), endConferenceEndContent] }))) : ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, {})) })) })));
178
182
  }
179
183
  exports.default = LiveStreamVideoConference;
@@ -11,6 +11,7 @@ import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
11
11
  import { LIVE_STREAM_DESCRIPTION_MAX_LENGTH, LIVE_STREAM_TITLE_MAX_LENGTH, LIVE_STREAM_SLUG_MAX_LENGTH } from '../../constants/LiveStream';
12
12
  import { PREFIX } from './constants';
13
13
  import UploadEventCover from '../EventForm/UploadEventCover';
14
+ import { generateRoomId } from '../../utils/liveStream';
14
15
  const classes = {
15
16
  root: `${PREFIX}-root`,
16
17
  form: `${PREFIX}-form`,
@@ -122,8 +123,9 @@ export default function LiveStreamForm(inProps) {
122
123
  }
123
124
  formData.append('title', field.title);
124
125
  formData.append('description', field.description);
126
+ // TODO: for testing
125
127
  setTimeout(() => {
126
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess({});
128
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess({ roomName: generateRoomId() });
127
129
  setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
128
130
  }, 1000);
129
131
  /*
@@ -1,6 +1,9 @@
1
1
  import { BoxProps } from '@mui/material';
2
2
  import { SCLiveStreamType } from '@selfcommunity/types';
3
+ import { LocalUserChoices } from '@livekit/components-react';
3
4
  import React from 'react';
5
+ import { ConnectionDetails } from './types';
6
+ import { LiveStreamVideoConferenceProps } from './LiveStreamVideoConference';
4
7
  import '@livekit/components-styles';
5
8
  export interface LiveStreamRoomProps extends BoxProps {
6
9
  /**
@@ -33,6 +36,21 @@ export interface LiveStreamRoomProps extends BoxProps {
33
36
  * Show description of livestream in prejoin
34
37
  */
35
38
  showPrejoinDescription?: boolean;
39
+ /**
40
+ * ConnectionDetails Object
41
+ * @default null
42
+ */
43
+ presetConnectionDetails?: ConnectionDetails;
44
+ /**
45
+ * LocalUserChoices Object
46
+ * @default null
47
+ */
48
+ presetPreJoinChoices?: LocalUserChoices;
49
+ /**
50
+ * Props to spread to LiveStreamVideoConference Component
51
+ * @default {}
52
+ */
53
+ LiveStreamVideoConferenceComponentProps?: LiveStreamVideoConferenceProps;
36
54
  /**
37
55
  * Any other properties
38
56
  */
@@ -1,5 +1,5 @@
1
1
  import { __awaiter, __rest } from "tslib";
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { Box, CircularProgress } from '@mui/material';
4
4
  import { styled } from '@mui/material/styles';
5
5
  import { useThemeProps } from '@mui/system';
@@ -19,6 +19,8 @@ const classes = {
19
19
  description: `${PREFIX}-description`,
20
20
  startPrejoinContent: `${PREFIX}-start-prejoin-content`,
21
21
  preJoin: `${PREFIX}-prejoin`,
22
+ preJoinLoading: `${PREFIX}-prejoin-loading`,
23
+ prejoinLoader: `${PREFIX}-prejoin-loader`,
22
24
  endPrejoinContent: `${PREFIX}-end-prejoin-content`,
23
25
  conference: `${PREFIX}-conference`,
24
26
  error: `${PREFIX}-error`
@@ -59,14 +61,14 @@ export default function LiveStreamRoom(inProps) {
59
61
  props: inProps,
60
62
  name: PREFIX
61
63
  });
62
- const { className, liveStream = null, showPrejoinTitle = true, showPrejoinDescription = false, startPrejoinContent, endPrejoinContent, connectionDetailsEndpoint } = props, rest = __rest(props, ["className", "liveStream", "showPrejoinTitle", "showPrejoinDescription", "startPrejoinContent", "endPrejoinContent", "connectionDetailsEndpoint"]);
64
+ const { className, liveStream = null, showPrejoinTitle = true, showPrejoinDescription = false, startPrejoinContent, endPrejoinContent, connectionDetailsEndpoint, presetConnectionDetails, presetPreJoinChoices, LiveStreamVideoConferenceComponentProps = {} } = props, rest = __rest(props, ["className", "liveStream", "showPrejoinTitle", "showPrejoinDescription", "startPrejoinContent", "endPrejoinContent", "connectionDetailsEndpoint", "presetConnectionDetails", "presetPreJoinChoices", "LiveStreamVideoConferenceComponentProps"]);
63
65
  // CONTEXT
64
66
  const scUserContext = useSCUser();
65
67
  const { preferences, features } = useSCPreferences();
66
68
  // INTL
67
69
  const intl = useIntl();
68
70
  // STATE
69
- const [preJoinChoices, setPreJoinChoices] = useState(undefined);
71
+ const [preJoinChoices, setPreJoinChoices] = useState(presetPreJoinChoices);
70
72
  const [loading, setLoading] = useState(false);
71
73
  const preJoinDefaults = useMemo(() => {
72
74
  var _a;
@@ -76,7 +78,7 @@ export default function LiveStreamRoom(inProps) {
76
78
  audioEnabled: true
77
79
  };
78
80
  }, [scUserContext.user]);
79
- const [connectionDetails, setConnectionDetails] = useState(undefined);
81
+ const [connectionDetails, setConnectionDetails] = useState(presetConnectionDetails);
80
82
  const liveStreamEnabled = true;
81
83
  /* const liveStreamEnabled = useMemo(
82
84
  () =>
@@ -88,6 +90,17 @@ export default function LiveStreamRoom(inProps) {
88
90
  [preferences, features]
89
91
  ); */
90
92
  const canCreateLiveStream = useMemo(() => true /* scUserContext?.user?.permission?.create_livestream */, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
93
+ const toggleAttrDisabledPrejoinActions = useCallback((disabled) => {
94
+ const container = document.querySelector('.lk-prejoin');
95
+ if (container) {
96
+ const buttons = container.querySelectorAll('button.lk-button');
97
+ buttons.forEach((button) => {
98
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
99
+ // @ts-ignore
100
+ button.disabled = disabled;
101
+ });
102
+ }
103
+ }, []);
91
104
  // HANDLERS
92
105
  /**
93
106
  * Handle PreJoin Submit
@@ -97,16 +110,18 @@ export default function LiveStreamRoom(inProps) {
97
110
  // eslint-disable-next-line no-constant-condition
98
111
  if ((liveStream || true) && connectionDetailsEndpoint) {
99
112
  setLoading(true);
113
+ toggleAttrDisabledPrejoinActions(true);
100
114
  setPreJoinChoices(values);
101
115
  const url = new URL(connectionDetailsEndpoint, window.location.origin);
102
- url.searchParams.append('roomName', generateRoomId());
116
+ url.searchParams.append('roomName', liveStream.roomName || generateRoomId());
103
117
  url.searchParams.append('participantName', (_b = scUserContext.user) === null || _b === void 0 ? void 0 : _b.username);
104
- // if (liveStream.region) {
105
- // url.searchParams.append('region', liveStream.region);
106
- // }
118
+ /* if (liveStream && liveStream.region) {
119
+ url.searchParams.append('region', liveStream.region);
120
+ } */
107
121
  const connectionDetailsResp = yield fetch(url.toString());
108
122
  const connectionDetailsData = yield connectionDetailsResp.json();
109
123
  setConnectionDetails(connectionDetailsData);
124
+ toggleAttrDisabledPrejoinActions(false);
110
125
  setLoading(false);
111
126
  }
112
127
  }), [scUserContext.user, connectionDetailsEndpoint, setPreJoinChoices, setConnectionDetails]);
@@ -123,5 +138,5 @@ export default function LiveStreamRoom(inProps) {
123
138
  /**
124
139
  * Renders root object
125
140
  */
126
- return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: _jsx(Box, Object.assign({ className: classes.content, "data-lk-theme": "default" }, { children: connectionDetails === undefined || preJoinChoices === undefined ? (_jsxs(_Fragment, { children: [startPrejoinContent && _jsx(Box, Object.assign({ className: classes.startPrejoinContent }, { children: startPrejoinContent })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.title) && _jsx(Box, Object.assign({ className: classes.title }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.title })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.description) && _jsx(Box, Object.assign({ className: classes.description }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.description })), _jsx(Box, Object.assign({ className: classes.preJoin }, { children: _jsx(PreJoin, { persistUserChoices: true, defaults: preJoinDefaults, onSubmit: handlePreJoinSubmit, onError: handlePreJoinError }) })), _jsx(Box, Object.assign({ className: classes.endPrejoinContent }, { children: endPrejoinContent }))] })) : (_jsx(Box, Object.assign({ className: classes.conference }, { children: _jsx(LiveStreamVideoConference, { connectionDetails: connectionDetails, userChoices: preJoinChoices, options: { codec: props.codec, hq: props.hq } }) }))) })) })));
141
+ return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: _jsx(Box, Object.assign({ className: classes.content, "data-lk-theme": "default" }, { children: connectionDetails === undefined || preJoinChoices === undefined ? (_jsxs(_Fragment, { children: [startPrejoinContent && _jsx(Box, Object.assign({ className: classes.startPrejoinContent }, { children: startPrejoinContent })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.title) && _jsx(Box, Object.assign({ className: classes.title }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.title })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.description) && _jsx(Box, Object.assign({ className: classes.description }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.description })), _jsxs(Box, Object.assign({ className: classNames(classes.preJoin, { [classes.preJoinLoading]: loading }) }, { children: [_jsx(PreJoin, { persistUserChoices: true, defaults: preJoinDefaults, onSubmit: handlePreJoinSubmit, onError: handlePreJoinError }), loading && (_jsx(Box, Object.assign({ className: classes.prejoinLoader }, { children: _jsx(CircularProgress, {}) })))] })), _jsx(Box, Object.assign({ className: classes.endPrejoinContent }, { children: endPrejoinContent }))] })) : (_jsx(Box, Object.assign({ className: classes.conference }, { children: _jsx(LiveStreamVideoConference, Object.assign({ connectionDetails: connectionDetails, userChoices: preJoinChoices, options: { codec: props.codec, hq: props.hq } }, LiveStreamVideoConferenceComponentProps)) }))) })) })));
127
142
  }
@@ -2,6 +2,7 @@ import { BoxProps } from '@mui/material';
2
2
  import { SCLiveStreamType } from '@selfcommunity/types/src/index';
3
3
  import { LiveKitRoomProps, LocalUserChoices } from '@livekit/components-react';
4
4
  import { VideoCodec } from 'livekit-client';
5
+ import React from 'react';
5
6
  import { ConnectionDetails } from '../types';
6
7
  export interface LiveStreamVideoConferenceProps extends BoxProps {
7
8
  /**
@@ -42,6 +43,14 @@ export interface LiveStreamVideoConferenceProps extends BoxProps {
42
43
  * @default {}
43
44
  */
44
45
  LiveKitRoomComponentsProps?: LiveKitRoomProps;
46
+ /**
47
+ * Element to be inserted before end conference content
48
+ */
49
+ startConferenceEndContent?: React.ReactNode | null;
50
+ /**
51
+ * Element to be inserted after end conference content
52
+ */
53
+ endConferenceEndContent?: React.ReactNode | null;
45
54
  /**
46
55
  * Any other properties
47
56
  */
@@ -1,9 +1,9 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { Box, CircularProgress } from '@mui/material';
3
+ import { Box, Button, CircularProgress, Typography } from '@mui/material';
4
4
  import { styled } from '@mui/material/styles';
5
5
  import { useThemeProps } from '@mui/system';
6
- import { useSCPreferences, useSCUser } from '@selfcommunity/react-core';
6
+ import { Link, useSCPreferences, useSCRouting, useSCUser } from '@selfcommunity/react-core';
7
7
  import classNames from 'classnames';
8
8
  import { PREFIX } from './constants';
9
9
  import { ConnectionState, formatChatMessageLinks, LiveKitRoom, VideoConference } from '@livekit/components-react';
@@ -11,10 +11,13 @@ import { useCallback, useMemo, useState } from 'react';
11
11
  import RecordingIndicator from './RecordingIndicator';
12
12
  import { defaultUserChoices } from '@livekit/components-core';
13
13
  import { defaultVideoOptions } from '../constants';
14
+ import { FormattedMessage } from 'react-intl';
14
15
  const classes = {
15
16
  root: `${PREFIX}-root`,
16
17
  title: `${PREFIX}-title`,
17
18
  content: `${PREFIX}-content`,
19
+ endConferenceWrap: `${PREFIX}-end-conference-wrap`,
20
+ btnBackHome: `${PREFIX}-btn-back-home`,
18
21
  actions: `${PREFIX}-actions`,
19
22
  error: `${PREFIX}-error`
20
23
  };
@@ -49,9 +52,10 @@ export default function LiveStreamVideoConference(inProps) {
49
52
  });
50
53
  const { className, liveStream = null, handleOnLeaveRoom, userChoices = defaultUserChoices, connectionDetails = {}, LiveKitRoomComponentsProps = {
51
54
  /* simulateParticipants: true */
52
- }, options = defaultVideoOptions } = props, rest = __rest(props, ["className", "liveStream", "handleOnLeaveRoom", "userChoices", "connectionDetails", "LiveKitRoomComponentsProps", "options"]);
55
+ }, startConferenceEndContent, endConferenceEndContent, options = defaultVideoOptions } = props, rest = __rest(props, ["className", "liveStream", "handleOnLeaveRoom", "userChoices", "connectionDetails", "LiveKitRoomComponentsProps", "startConferenceEndContent", "endConferenceEndContent", "options"]);
53
56
  // CONTEXT
54
57
  const scUserContext = useSCUser();
58
+ const scRoutingContext = useSCRouting();
55
59
  const { preferences, features } = useSCPreferences();
56
60
  // Passphrase
57
61
  // const e2eePassphrase = typeof window !== 'undefined' && decodePassphrase(location.hash.substring(1));
@@ -172,5 +176,5 @@ export default function LiveStreamVideoConference(inProps) {
172
176
  /**
173
177
  * Renders root object
174
178
  */
175
- return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: liveActive && !error ? (_jsx(_Fragment, { children: _jsxs(LiveKitRoom, Object.assign({ connect: Boolean(e2eeSetupComplete && liveActive), token: connectionDetails['participantToken'], serverUrl: connectionDetails['serverUrl'], connectOptions: connectOptions, video: userChoices.videoEnabled, audio: userChoices.audioEnabled, onDisconnected: handleOnLeave, onEncryptionError: handleEncryptionError, onError: handleError }, LiveKitRoomComponentsProps, { children: [_jsx(VideoConference, { chatMessageFormatter: formatChatMessageLinks }), _jsx(RecordingIndicator, {}), _jsx(ConnectionState, {})] })) })) : (_jsx(_Fragment, { children: error ? error : liveActive === false ? _jsx(_Fragment, { children: "Grazie!" }) : _jsx(CircularProgress, {}) })) })));
179
+ return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: liveActive && !error ? (_jsx(_Fragment, { children: _jsxs(LiveKitRoom, Object.assign({ connect: Boolean(e2eeSetupComplete && liveActive), token: connectionDetails['participantToken'], serverUrl: connectionDetails['serverUrl'], connectOptions: connectOptions, video: userChoices.videoEnabled, audio: userChoices.audioEnabled, onDisconnected: handleOnLeave, onEncryptionError: handleEncryptionError, onError: handleError }, LiveKitRoomComponentsProps, { children: [_jsx(VideoConference, { chatMessageFormatter: formatChatMessageLinks }), _jsx(RecordingIndicator, {}), _jsx(ConnectionState, {})] })) })) : (_jsx(_Fragment, { children: error ? (error) : liveActive === false ? (_jsxs(Box, Object.assign({ className: classes.endConferenceWrap }, { children: [startConferenceEndContent, _jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamRoom.conference.end", defaultMessage: "ui.liveStreamRoom.conference.end" }) })), _jsx(Button, Object.assign({ color: "secondary", component: Link, to: '/', className: classes.btnBackHome }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamRoom.button.backHome", defaultMessage: "ui.liveStreamRoom.button.backHome" }) })), endConferenceEndContent] }))) : (_jsx(CircularProgress, {})) })) })));
176
180
  }