@selfcommunity/react-ui 0.8.0-live.59 → 0.8.0-live.61
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.
- package/lib/cjs/components/EventForm/EventAddress.js +5 -2
- package/lib/cjs/components/LiveStreamForm/LiveStreamForm.js +1 -3
- package/lib/cjs/components/LiveStreamForm/LiveStreamFormSettings.js +1 -1
- package/lib/cjs/components/LiveStreamForm/constants.d.ts +2 -2
- package/lib/cjs/components/LiveStreamForm/constants.js +2 -2
- package/lib/cjs/components/LiveStreamRoom/LiveStreamRoom.js +5 -6
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.d.ts +29 -0
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.js +62 -0
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/DisconnectButton.d.ts +10 -0
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/DisconnectButton.js +16 -0
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamProvider.d.ts +17 -0
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamProvider.js +13 -0
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamVideoConference.d.ts +0 -6
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamVideoConference.js +16 -88
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.d.ts +1 -0
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.js +2 -2
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTileActions.js +33 -26
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTileAvatar.d.ts +2 -2
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTileAvatar.js +14 -3
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.d.ts +1 -7
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.js +5 -3
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/SettingsMenuToggle.d.ts +19 -0
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/SettingsMenuToggle.js +35 -0
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.d.ts +2 -17
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.js +8 -22
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/utils.d.ts +27 -0
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/utils.js +82 -0
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.js +1 -1
- package/lib/esm/components/EventForm/EventAddress.js +6 -3
- package/lib/esm/components/LiveStreamForm/LiveStreamForm.js +2 -4
- package/lib/esm/components/LiveStreamForm/LiveStreamFormSettings.js +1 -1
- package/lib/esm/components/LiveStreamForm/constants.d.ts +2 -2
- package/lib/esm/components/LiveStreamForm/constants.js +2 -2
- package/lib/esm/components/LiveStreamRoom/LiveStreamRoom.js +5 -6
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.d.ts +29 -0
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.js +58 -0
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/DisconnectButton.d.ts +10 -0
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/DisconnectButton.js +12 -0
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamProvider.d.ts +17 -0
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamProvider.js +9 -0
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamVideoConference.d.ts +0 -6
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamVideoConference.js +17 -89
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.d.ts +1 -0
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.js +2 -2
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTileActions.js +35 -28
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTileAvatar.d.ts +2 -2
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTileAvatar.js +13 -2
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.d.ts +1 -7
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.js +5 -3
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/SettingsMenuToggle.d.ts +19 -0
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/SettingsMenuToggle.js +30 -0
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.d.ts +2 -17
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.js +9 -23
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/utils.d.ts +27 -0
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/utils.js +74 -0
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.js +1 -1
- package/lib/umd/{43.js → 32.js} +2 -2
- package/lib/umd/react-ui.js +1 -1
- package/package.json +8 -7
- /package/lib/umd/{43.js.LICENSE.txt → 32.js.LICENSE.txt} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SCLiveStreamViewType } from '@selfcommunity/types';
|
|
2
2
|
export declare const PREFIX = "SCLiveStreamForm";
|
|
3
3
|
export declare const LIVESTREAM_DEFAULT_SETTINGS: {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
muteParticipants: boolean;
|
|
5
|
+
hideParticipantsList: boolean;
|
|
6
6
|
automaticallyNotifyFollowers: boolean;
|
|
7
7
|
disableVideo: boolean;
|
|
8
8
|
disableChat: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SCLiveStreamViewType } from '@selfcommunity/types';
|
|
2
2
|
export const PREFIX = 'SCLiveStreamForm';
|
|
3
3
|
export const LIVESTREAM_DEFAULT_SETTINGS = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
muteParticipants: true,
|
|
5
|
+
hideParticipantsList: false,
|
|
6
6
|
automaticallyNotifyFollowers: false,
|
|
7
7
|
disableVideo: true,
|
|
8
8
|
disableChat: false,
|
|
@@ -15,6 +15,7 @@ import { LiveStreamService } from '@selfcommunity/api-services';
|
|
|
15
15
|
import { Logger } from '@selfcommunity/utils';
|
|
16
16
|
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
17
17
|
import { PreJoin } from './LiveStreamVideoConference/PreJoin';
|
|
18
|
+
import { LiveStreamContext } from './LiveStreamVideoConference/LiveStreamProvider';
|
|
18
19
|
const classes = {
|
|
19
20
|
root: `${PREFIX}-root`,
|
|
20
21
|
content: `${PREFIX}-content`,
|
|
@@ -77,7 +78,7 @@ export default function LiveStreamRoom(inProps) {
|
|
|
77
78
|
return {
|
|
78
79
|
username: ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.username) || '',
|
|
79
80
|
videoEnabled: ((_b = scLiveStream === null || scLiveStream === void 0 ? void 0 : scLiveStream.settings) === null || _b === void 0 ? void 0 : _b.disableVideo) === false,
|
|
80
|
-
audioEnabled: ((_c = scLiveStream === null || scLiveStream === void 0 ? void 0 : scLiveStream.settings) === null || _c === void 0 ? void 0 : _c.
|
|
81
|
+
audioEnabled: ((_c = scLiveStream === null || scLiveStream === void 0 ? void 0 : scLiveStream.settings) === null || _c === void 0 ? void 0 : _c.muteParticipants) === false
|
|
81
82
|
};
|
|
82
83
|
}, [scUserContext.user, scLiveStream]);
|
|
83
84
|
const [connectionDetails, setConnectionDetails] = useState(presetConnectionDetails);
|
|
@@ -97,8 +98,6 @@ export default function LiveStreamRoom(inProps) {
|
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
}, []);
|
|
100
|
-
const canUseAudio = useMemo(() => { var _a; return (scUserContext.user && liveStream && liveStream.host.id === scUserContext.user.id) || (liveStream && !((_a = liveStream === null || liveStream === void 0 ? void 0 : liveStream.settings) === null || _a === void 0 ? void 0 : _a.muteParticipant)); }, [scUserContext, liveStream]);
|
|
101
|
-
const canUseVideo = useMemo(() => { var _a; return (scUserContext.user && liveStream && liveStream.host.id === scUserContext.user.id) || (liveStream && !((_a = liveStream === null || liveStream === void 0 ? void 0 : liveStream.settings) === null || _a === void 0 ? void 0 : _a.disableVideo)); }, [scUserContext, liveStream]);
|
|
102
101
|
// HANDLERS
|
|
103
102
|
/**
|
|
104
103
|
* Handle PreJoin Submit
|
|
@@ -126,14 +125,14 @@ export default function LiveStreamRoom(inProps) {
|
|
|
126
125
|
/**
|
|
127
126
|
* User must be authenticated
|
|
128
127
|
*/
|
|
129
|
-
if (
|
|
128
|
+
if (!scLiveStream || !scUserContext.user || !liveStreamEnabled) {
|
|
130
129
|
return _jsx(CircularProgress, {});
|
|
131
130
|
}
|
|
132
131
|
/**
|
|
133
132
|
* Renders root object
|
|
134
133
|
*/
|
|
135
|
-
return (_jsx(Root, Object.assign({ id: id, 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 })), (scLiveStream === null || scLiveStream === void 0 ? void 0 : scLiveStream.title) && (_jsx(Typography, Object.assign({ component: 'div', variant: "h5", className: classes.title }, { children: scLiveStream === null || scLiveStream === void 0 ? void 0 : scLiveStream.title }))), (scLiveStream === null || scLiveStream === void 0 ? void 0 : scLiveStream.description) && (_jsx(Typography, Object.assign({ component: 'div', variant: "body1", className: classes.description }, { children: scLiveStream === null || scLiveStream === void 0 ? void 0 : scLiveStream.description }))), _jsxs(Box, Object.assign({ className: classNames(classes.preJoin, { [classes.preJoinLoading]: loading }) }, { children: [_jsx(
|
|
134
|
+
return (_jsx(Root, Object.assign({ id: id, 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 })), (scLiveStream === null || scLiveStream === void 0 ? void 0 : scLiveStream.title) && (_jsx(Typography, Object.assign({ component: 'div', variant: "h5", className: classes.title }, { children: scLiveStream === null || scLiveStream === void 0 ? void 0 : scLiveStream.title }))), (scLiveStream === null || scLiveStream === void 0 ? void 0 : scLiveStream.description) && (_jsx(Typography, Object.assign({ component: 'div', variant: "body1", className: classes.description }, { children: scLiveStream === null || scLiveStream === void 0 ? void 0 : scLiveStream.description }))), _jsxs(Box, Object.assign({ className: classNames(classes.preJoin, { [classes.preJoinLoading]: loading }) }, { children: [_jsx(LiveStreamContext.Provider, Object.assign({ value: { liveStream: scLiveStream } }, { children: _jsx(PreJoin, { defaults: preJoinDefaults, onSubmit: handlePreJoinSubmit, onError: handlePreJoinError }) })), loading && (_jsxs(Box, Object.assign({ className: classes.prejoinLoader }, { children: [_jsx(CircularProgress, {}), _jsx(Typography, Object.assign({ component: 'div', variant: "body2" }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamRoom.connecting", defaultMessage: "ui.liveStreamRoom.connecting" }) }))] })))] })), _jsxs(Box, Object.assign({ className: classes.endPrejoinContent }, { children: [Boolean(scUserContext.user &&
|
|
136
135
|
scUserContext.user.id !== scLiveStream.host.id &&
|
|
137
136
|
scLiveStream &&
|
|
138
|
-
(((_a = scLiveStream.settings) === null || _a === void 0 ? void 0 : _a.
|
|
137
|
+
(((_a = scLiveStream.settings) === null || _a === void 0 ? void 0 : _a.muteParticipants) || (scLiveStream && ((_b = scLiveStream.settings) === null || _b === void 0 ? void 0 : _b.disableVideo)))) && (_jsxs(Alert, Object.assign({ variant: "filled", severity: "error" }, { children: [scLiveStream && ((_c = scLiveStream.settings) === null || _c === void 0 ? void 0 : _c.muteParticipants) && (_jsxs(_Fragment, { children: [_jsx(FormattedMessage, { id: "ui.liveStreamRoom.hostDisableMicrophone", defaultMessage: "ui.liveStreamRoom.hostDisableMicrophone" }), _jsx("br", {})] })), scLiveStream && ((_d = scLiveStream.settings) === null || _d === void 0 ? void 0 : _d.disableVideo) && (_jsx(_Fragment, { children: _jsx(FormattedMessage, { id: "ui.liveStreamRoom.hostDisableVideo", defaultMessage: "ui.liveStreamRoom.hostDisableVideo" }) }))] }))), endPrejoinContent] }))] })) : (_jsx(Box, Object.assign({ className: classes.conference }, { children: _jsx(LiveStreamContext.Provider, Object.assign({ value: { liveStream: scLiveStream } }, { children: _jsx(LiveStreamVideoConference, Object.assign({ connectionDetails: connectionDetails, userChoices: preJoinChoices }, LiveStreamVideoConferenceComponentProps)) })) }))) })) })));
|
|
139
138
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Track } from 'livekit-client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
/** @public */
|
|
4
|
+
export type ControlBarControls = {
|
|
5
|
+
microphone?: boolean;
|
|
6
|
+
camera?: boolean;
|
|
7
|
+
chat?: boolean;
|
|
8
|
+
screenShare?: boolean;
|
|
9
|
+
leave?: boolean;
|
|
10
|
+
settings?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export interface ControlBarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
13
|
+
onDeviceError?: (error: {
|
|
14
|
+
source: Track.Source;
|
|
15
|
+
error: Error;
|
|
16
|
+
}) => void;
|
|
17
|
+
variation?: 'minimal' | 'verbose' | 'textOnly';
|
|
18
|
+
controls?: ControlBarControls;
|
|
19
|
+
/**
|
|
20
|
+
* If `true`, the user's device choices will be persisted.
|
|
21
|
+
* This will enable the user to have the same device choices when they rejoin the room.
|
|
22
|
+
*/
|
|
23
|
+
saveUserChoices?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The `ControlBar` prefab gives the user the basic user interface to control their
|
|
27
|
+
* media devices (camera, microphone and screen share), open the `Chat` and leave the room.
|
|
28
|
+
*/
|
|
29
|
+
export declare function ControlBar({ variation, controls, saveUserChoices, onDeviceError, ...props }: ControlBarProps): JSX.Element;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Track } from 'livekit-client';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { supportsScreenSharing } from '@livekit/components-core';
|
|
6
|
+
import { ChatIcon, ChatToggle, GearIcon, LeaveIcon, MediaDeviceMenu, StartMediaButton, useLocalParticipantPermissions, useMaybeLayoutContext, usePersistentUserChoices } from '@livekit/components-react';
|
|
7
|
+
import { TrackToggle } from './TrackToggle';
|
|
8
|
+
import { useMediaQuery } from '@mui/material';
|
|
9
|
+
import { SettingsMenuToggle } from './SettingsMenuToggle';
|
|
10
|
+
import { DisconnectButton } from './DisconnectButton';
|
|
11
|
+
import { mergeProps } from './utils';
|
|
12
|
+
/**
|
|
13
|
+
* The `ControlBar` prefab gives the user the basic user interface to control their
|
|
14
|
+
* media devices (camera, microphone and screen share), open the `Chat` and leave the room.
|
|
15
|
+
*/
|
|
16
|
+
export function ControlBar(_a) {
|
|
17
|
+
var _b, _c, _d, _e, _f;
|
|
18
|
+
var { variation, controls, saveUserChoices = true, onDeviceError } = _a, props = __rest(_a, ["variation", "controls", "saveUserChoices", "onDeviceError"]);
|
|
19
|
+
const [isChatOpen, setIsChatOpen] = React.useState(false);
|
|
20
|
+
const layoutContext = useMaybeLayoutContext();
|
|
21
|
+
React.useEffect(() => {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
if (((_a = layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.widget.state) === null || _a === void 0 ? void 0 : _a.showChat) !== undefined) {
|
|
24
|
+
setIsChatOpen((_b = layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.widget.state) === null || _b === void 0 ? void 0 : _b.showChat);
|
|
25
|
+
}
|
|
26
|
+
}, [(_b = layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.widget.state) === null || _b === void 0 ? void 0 : _b.showChat]);
|
|
27
|
+
const isTooLittleSpace = useMediaQuery(`(max-width: ${isChatOpen ? 1000 : 760}px)`);
|
|
28
|
+
const defaultVariation = isTooLittleSpace ? 'minimal' : 'verbose';
|
|
29
|
+
variation !== null && variation !== void 0 ? variation : (variation = defaultVariation);
|
|
30
|
+
const visibleControls = Object.assign({ leave: true }, controls);
|
|
31
|
+
const localPermissions = useLocalParticipantPermissions();
|
|
32
|
+
if (!localPermissions) {
|
|
33
|
+
visibleControls.camera = false;
|
|
34
|
+
visibleControls.chat = false;
|
|
35
|
+
visibleControls.microphone = false;
|
|
36
|
+
visibleControls.screenShare = false;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
(_c = visibleControls.camera) !== null && _c !== void 0 ? _c : (visibleControls.camera = localPermissions.canPublish);
|
|
40
|
+
(_d = visibleControls.microphone) !== null && _d !== void 0 ? _d : (visibleControls.microphone = localPermissions.canPublish);
|
|
41
|
+
(_e = visibleControls.screenShare) !== null && _e !== void 0 ? _e : (visibleControls.screenShare = localPermissions.canPublish);
|
|
42
|
+
(_f = visibleControls.chat) !== null && _f !== void 0 ? _f : (visibleControls.chat = localPermissions.canPublishData && (controls === null || controls === void 0 ? void 0 : controls.chat));
|
|
43
|
+
}
|
|
44
|
+
const showIcon = React.useMemo(() => variation === 'minimal' || variation === 'verbose', [variation]);
|
|
45
|
+
const showText = React.useMemo(() => variation === 'textOnly' || variation === 'verbose', [variation]);
|
|
46
|
+
const browserSupportsScreenSharing = supportsScreenSharing();
|
|
47
|
+
const [isScreenShareEnabled, setIsScreenShareEnabled] = React.useState(false);
|
|
48
|
+
const onScreenShareChange = React.useCallback((enabled) => {
|
|
49
|
+
setIsScreenShareEnabled(enabled);
|
|
50
|
+
}, [setIsScreenShareEnabled]);
|
|
51
|
+
const htmlProps = mergeProps({ className: 'lk-control-bar' }, props);
|
|
52
|
+
const { saveAudioInputEnabled, saveVideoInputEnabled, saveAudioInputDeviceId, saveVideoInputDeviceId } = usePersistentUserChoices({
|
|
53
|
+
preventSave: !saveUserChoices
|
|
54
|
+
});
|
|
55
|
+
const microphoneOnChange = React.useCallback((enabled, isUserInitiated) => (isUserInitiated ? saveAudioInputEnabled(enabled) : null), [saveAudioInputEnabled]);
|
|
56
|
+
const cameraOnChange = React.useCallback((enabled, isUserInitiated) => (isUserInitiated ? saveVideoInputEnabled(enabled) : null), [saveVideoInputEnabled]);
|
|
57
|
+
return (_jsxs("div", Object.assign({}, htmlProps, { children: [visibleControls.microphone && (_jsxs("div", Object.assign({ className: "lk-button-group" }, { children: [_jsx(_Fragment, { children: _jsx(TrackToggle, Object.assign({ source: Track.Source.Microphone, showIcon: showIcon, onChange: microphoneOnChange, onDeviceError: (error) => onDeviceError === null || onDeviceError === void 0 ? void 0 : onDeviceError({ source: Track.Source.Microphone, error }) }, { children: showText && 'Microphone' })) }), _jsx("div", Object.assign({ className: "lk-button-group-menu" }, { children: _jsx(MediaDeviceMenu, { kind: "audioinput", onActiveDeviceChange: (_kind, deviceId) => saveAudioInputDeviceId(deviceId !== null && deviceId !== void 0 ? deviceId : '') }) }))] }))), visibleControls.camera && (_jsxs("div", Object.assign({ className: "lk-button-group" }, { children: [_jsx(_Fragment, { children: _jsx(TrackToggle, Object.assign({ source: Track.Source.Camera, showIcon: showIcon, onChange: cameraOnChange, onDeviceError: (error) => onDeviceError === null || onDeviceError === void 0 ? void 0 : onDeviceError({ source: Track.Source.Camera, error }) }, { children: showText && 'Camera' })) }), _jsx("div", Object.assign({ className: "lk-button-group-menu" }, { children: _jsx(MediaDeviceMenu, { kind: "videoinput", onActiveDeviceChange: (_kind, deviceId) => saveVideoInputDeviceId(deviceId !== null && deviceId !== void 0 ? deviceId : '') }) }))] }))), visibleControls.screenShare && browserSupportsScreenSharing && (_jsx(_Fragment, { children: _jsx(TrackToggle, Object.assign({ source: Track.Source.ScreenShare, captureOptions: { audio: true, selfBrowserSurface: 'include' }, showIcon: showIcon, onChange: onScreenShareChange, onDeviceError: (error) => onDeviceError === null || onDeviceError === void 0 ? void 0 : onDeviceError({ source: Track.Source.ScreenShare, error }) }, { children: showText && (isScreenShareEnabled ? 'Stop screen share' : 'Share screen') })) })), visibleControls.chat && (_jsx(_Fragment, { children: _jsxs(ChatToggle, { children: [showIcon && _jsx(ChatIcon, {}), showText && 'Chat'] }) })), visibleControls.settings && (_jsx(_Fragment, { children: _jsxs(SettingsMenuToggle, { children: [showIcon && _jsx(GearIcon, {}), showText && 'Settings'] }) })), visibleControls.leave && (_jsx(_Fragment, { children: _jsxs(DisconnectButton, { children: [showIcon && _jsx(LeaveIcon, {}), showText && 'Leave'] }) })), _jsx(StartMediaButton, {})] })));
|
|
58
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/** @public */
|
|
3
|
+
export interface DisconnectButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
4
|
+
stopTracks?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The `DisconnectButton` is a basic html button with the added ability to disconnect from a LiveKit room.
|
|
8
|
+
* Normally this is the big red button that allows end users to leave the video or audio call.
|
|
9
|
+
*/
|
|
10
|
+
export declare const DisconnectButton: (props: DisconnectButtonProps & React.RefAttributes<HTMLButtonElement>) => React.ReactNode;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useDisconnectButton } from '@livekit/components-react';
|
|
4
|
+
/**
|
|
5
|
+
* The `DisconnectButton` is a basic html button with the added ability to disconnect from a LiveKit room.
|
|
6
|
+
* Normally this is the big red button that allows end users to leave the video or audio call.
|
|
7
|
+
*/
|
|
8
|
+
export const DisconnectButton =
|
|
9
|
+
/* @__PURE__ */ React.forwardRef(function DisconnectButton(props, ref) {
|
|
10
|
+
const { buttonProps } = useDisconnectButton(props);
|
|
11
|
+
return (_jsx("button", Object.assign({ ref: ref }, buttonProps, { children: props.children })));
|
|
12
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SCLiveStreamType } from '@selfcommunity/types';
|
|
3
|
+
/**
|
|
4
|
+
* Interface LiveStreamContextType
|
|
5
|
+
*/
|
|
6
|
+
export interface LiveStreamContextType {
|
|
7
|
+
/**
|
|
8
|
+
* Options
|
|
9
|
+
*/
|
|
10
|
+
liveStream: SCLiveStreamType;
|
|
11
|
+
}
|
|
12
|
+
export declare const LiveStreamContext: import("react").Context<LiveStreamContextType>;
|
|
13
|
+
/**
|
|
14
|
+
* Let's only export the `useLiveStream` hook instead of the context.
|
|
15
|
+
* We only want to use the hook directly and never the context component.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useLiveStream(): LiveStreamContextType;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
export const LiveStreamContext = createContext({});
|
|
3
|
+
/**
|
|
4
|
+
* Let's only export the `useLiveStream` hook instead of the context.
|
|
5
|
+
* We only want to use the hook directly and never the context component.
|
|
6
|
+
*/
|
|
7
|
+
export function useLiveStream() {
|
|
8
|
+
return useContext(LiveStreamContext);
|
|
9
|
+
}
|
package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamVideoConference.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BoxProps } from '@mui/material';
|
|
2
|
-
import { SCLiveStreamType } from '@selfcommunity/types/src/index';
|
|
3
2
|
import { LiveKitRoomProps, LocalUserChoices, VideoConferenceProps } from '@livekit/components-react';
|
|
4
3
|
import { VideoCodec } from 'livekit-client';
|
|
5
4
|
import React from 'react';
|
|
@@ -10,11 +9,6 @@ export interface LiveStreamVideoConferenceProps extends BoxProps {
|
|
|
10
9
|
* @default null
|
|
11
10
|
*/
|
|
12
11
|
className?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Livestream Object
|
|
15
|
-
* @default null
|
|
16
|
-
*/
|
|
17
|
-
liveStream?: SCLiveStreamType;
|
|
18
12
|
/**
|
|
19
13
|
* User choices
|
|
20
14
|
*/
|
package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamVideoConference.js
CHANGED
|
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
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 { Link,
|
|
6
|
+
import { Link, useSCUser } from '@selfcommunity/react-core';
|
|
7
|
+
import { SCLiveStreamViewType } from '@selfcommunity/types';
|
|
7
8
|
import classNames from 'classnames';
|
|
8
9
|
import { PREFIX } from './constants';
|
|
9
10
|
import { ConnectionState, formatChatMessageLinks, LayoutContextProvider, LiveKitRoom } from '@livekit/components-react';
|
|
@@ -12,6 +13,7 @@ import { defaultUserChoices } from '@livekit/components-core';
|
|
|
12
13
|
import { defaultVideoOptions } from '../constants';
|
|
13
14
|
import { FormattedMessage } from 'react-intl';
|
|
14
15
|
import { VideoConference } from './VideoConference';
|
|
16
|
+
import { useLiveStream } from './LiveStreamProvider';
|
|
15
17
|
const classes = {
|
|
16
18
|
root: `${PREFIX}-root`,
|
|
17
19
|
title: `${PREFIX}-title`,
|
|
@@ -50,103 +52,29 @@ export default function LiveStreamVideoConference(inProps) {
|
|
|
50
52
|
props: inProps,
|
|
51
53
|
name: PREFIX
|
|
52
54
|
});
|
|
53
|
-
const { className,
|
|
55
|
+
const { className, handleOnLeaveRoom, userChoices = defaultUserChoices, connectionDetails = {}, LiveKitRoomComponentProps = {
|
|
54
56
|
/* simulateParticipants: true */
|
|
55
|
-
}, VideoConferenceComponentProps = {}, startConferenceEndContent, endConferenceEndContent, options = defaultVideoOptions } = props, rest = __rest(props, ["className", "
|
|
57
|
+
}, VideoConferenceComponentProps = {}, startConferenceEndContent, endConferenceEndContent, options = defaultVideoOptions } = props, rest = __rest(props, ["className", "handleOnLeaveRoom", "userChoices", "connectionDetails", "LiveKitRoomComponentProps", "VideoConferenceComponentProps", "startConferenceEndContent", "endConferenceEndContent", "options"]);
|
|
56
58
|
// CONTEXT
|
|
57
59
|
const scUserContext = useSCUser();
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
// Passphrase
|
|
61
|
-
// const e2eePassphrase = typeof window !== 'undefined' && decodePassphrase(location.hash.substring(1));
|
|
62
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
63
|
-
// @ts-ignore
|
|
64
|
-
// const worker = typeof window !== 'undefined' && e2eePassphrase && new Worker(new URL('livekit-client/e2ee-worker', import.meta.url));
|
|
65
|
-
// const e2eeEnabled = !!(e2eePassphrase && worker);
|
|
66
|
-
// const keyProvider = new ExternalE2EEKeyProvider();
|
|
67
|
-
const [e2eeSetupComplete, setE2eeSetupComplete] = useState(true);
|
|
60
|
+
const { liveStream } = useLiveStream();
|
|
61
|
+
// STATE
|
|
68
62
|
const [liveActive, setLiveActive] = useState(true);
|
|
69
63
|
const [error, setError] = useState(null);
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
[preferences]
|
|
80
|
-
); */
|
|
81
|
-
// Room options
|
|
82
|
-
/* const roomOptions = useMemo((): RoomOptions => {
|
|
83
|
-
let videoCodec: VideoCodec | undefined = options.codec ? options.codec : defaultVideoOptions.codec;
|
|
84
|
-
if (e2eeEnabled && (videoCodec === 'av1' || videoCodec === 'vp9')) {
|
|
85
|
-
videoCodec = undefined;
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
// emptyTimeout: 3 * 60, // 3 minutes
|
|
89
|
-
// maxParticipants: liveStreamRoomMaxParticipants,
|
|
90
|
-
videoCaptureDefaults: {
|
|
91
|
-
deviceId: userChoices.videoDeviceId ?? undefined,
|
|
92
|
-
resolution: options.hq ? VideoPresets.h2160 : VideoPresets.h720
|
|
93
|
-
},
|
|
94
|
-
publishDefaults: {
|
|
95
|
-
dtx: false,
|
|
96
|
-
videoSimulcastLayers: options.hq ? [VideoPresets.h1080, VideoPresets.h720] : [VideoPresets.h540, VideoPresets.h216],
|
|
97
|
-
red: !e2eeEnabled,
|
|
98
|
-
videoCodec
|
|
99
|
-
},
|
|
100
|
-
audioCaptureDefaults: {
|
|
101
|
-
deviceId: userChoices.audioDeviceId ?? undefined
|
|
102
|
-
},
|
|
103
|
-
adaptiveStream: {pixelDensity: 'screen'},
|
|
104
|
-
dynacast: true,
|
|
105
|
-
e2ee: e2eeEnabled
|
|
106
|
-
? {
|
|
107
|
-
keyProvider,
|
|
108
|
-
worker
|
|
109
|
-
}
|
|
110
|
-
: undefined
|
|
111
|
-
};
|
|
112
|
-
}, [liveStreamRoomMaxParticipants, userChoices, options.hq, options.codec]); */
|
|
113
|
-
// Create room - only initial
|
|
114
|
-
/* const room = useMemo(() => {
|
|
115
|
-
const room = new Room();
|
|
116
|
-
return new Room(roomOptions);
|
|
117
|
-
}, [liveStreamRoomMaxParticipants]); */
|
|
64
|
+
// PERMISSIONS
|
|
65
|
+
const canUseAudio = useMemo(() => { var _a; return scUserContext.user && liveStream && (liveStream.host.id === scUserContext.user.id || (liveStream && !((_a = liveStream === null || liveStream === void 0 ? void 0 : liveStream.settings) === null || _a === void 0 ? void 0 : _a.muteParticipants))); }, [scUserContext, liveStream]);
|
|
66
|
+
const canUseVideo = useMemo(() => { var _a; return scUserContext.user && liveStream && (liveStream.host.id === scUserContext.user.id || (liveStream && !((_a = liveStream === null || liveStream === void 0 ? void 0 : liveStream.settings) === null || _a === void 0 ? void 0 : _a.disableVideo))); }, [scUserContext, liveStream]);
|
|
67
|
+
const canUseChat = useMemo(() => { var _a; return scUserContext.user && liveStream && liveStream && !((_a = liveStream === null || liveStream === void 0 ? void 0 : liveStream.settings) === null || _a === void 0 ? void 0 : _a.disableChat); }, [scUserContext, liveStream]);
|
|
68
|
+
const canUseShareScreen = useMemo(() => { var _a; return scUserContext.user && liveStream && (liveStream.host.id === scUserContext.user.id || (liveStream && !((_a = liveStream === null || liveStream === void 0 ? void 0 : liveStream.settings) === null || _a === void 0 ? void 0 : _a.disableShareScreen))); }, [scUserContext, liveStream]);
|
|
69
|
+
const speakerFocused = useMemo(() => (scUserContext.user && liveStream && liveStream.settings.view === SCLiveStreamViewType.SPEAKER ? liveStream.host : null), [scUserContext, liveStream]);
|
|
70
|
+
console.log(canUseChat);
|
|
71
|
+
console.log(speakerFocused);
|
|
72
|
+
// CONNECT OPTIONS
|
|
118
73
|
const connectOptions = useMemo(() => {
|
|
119
74
|
return {
|
|
120
75
|
autoSubscribe: true
|
|
121
76
|
};
|
|
122
77
|
}, []);
|
|
123
|
-
/* useEffect(() => {
|
|
124
|
-
if (room) {
|
|
125
|
-
if (e2eeEnabled) {
|
|
126
|
-
keyProvider
|
|
127
|
-
.setKey(decodePassphrase(e2eePassphrase))
|
|
128
|
-
.then(() => {
|
|
129
|
-
room.setE2EEEnabled(true).catch((e) => {
|
|
130
|
-
if (e instanceof DeviceUnsupportedError) {
|
|
131
|
-
alert(
|
|
132
|
-
`You're trying to join an encrypted meeting, but your browser does not support it. Please update it to the latest version and try again.`
|
|
133
|
-
);
|
|
134
|
-
console.error(e);
|
|
135
|
-
} else {
|
|
136
|
-
throw e;
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
})
|
|
140
|
-
.then(() => {
|
|
141
|
-
setE2eeSetupComplete(true);
|
|
142
|
-
setLiveActive(true);
|
|
143
|
-
});
|
|
144
|
-
} else {
|
|
145
|
-
setE2eeSetupComplete(true);
|
|
146
|
-
setLiveActive(true);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}, [e2eeEnabled, room, e2eePassphrase]); */
|
|
150
78
|
// HANDLERS
|
|
151
79
|
/**
|
|
152
80
|
* Handle on leave
|
|
@@ -180,5 +108,5 @@ export default function LiveStreamVideoConference(inProps) {
|
|
|
180
108
|
/**
|
|
181
109
|
* Renders root object
|
|
182
110
|
*/
|
|
183
|
-
return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: liveActive && !error ? (_jsx(_Fragment, { children: _jsx(LiveKitRoom, Object.assign({ connect: Boolean(
|
|
111
|
+
return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: liveActive && !error ? (_jsx(_Fragment, { children: _jsx(LiveKitRoom, Object.assign({ connect: Boolean(liveActive), token: connectionDetails['participantToken'], serverUrl: connectionDetails['serverUrl'], connectOptions: connectOptions, video: userChoices.videoEnabled, audio: userChoices.audioEnabled, onDisconnected: handleOnLeave, onEncryptionError: handleEncryptionError, onError: handleError }, LiveKitRoomComponentProps, { children: _jsxs(LayoutContextProvider, { children: [_jsx(VideoConference, Object.assign({ chatMessageFormatter: formatChatMessageLinks }, (speakerFocused && { speakerFocused: liveStream.host }), VideoConferenceComponentProps, { disableMicrophone: !canUseAudio, disableCamera: !canUseVideo, disableChat: !canUseChat, disableShareScreen: !canUseShareScreen })), _jsx(ConnectionState, {})] }) })) })) : (_jsx(_Fragment, { children: error ? (_jsxs(Box, Object.assign({ className: classes.endConferenceWrap }, { children: [startConferenceEndContent, error, endConferenceEndContent] }))) : 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({ variant: "contained", color: "secondary", component: Link, to: '/', className: classes.btnBackHome }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamRoom.button.backHome", defaultMessage: "ui.liveStreamRoom.button.backHome" }) })), endConferenceEndContent] }))) : (_jsx(CircularProgress, {})) })) })));
|
|
184
112
|
}
|
|
@@ -18,6 +18,7 @@ export interface ParticipantTileProps extends React.HTMLAttributes<HTMLDivElemen
|
|
|
18
18
|
/** The track reference to display. */
|
|
19
19
|
trackRef?: TrackReferenceOrPlaceholder;
|
|
20
20
|
disableSpeakingIndicator?: boolean;
|
|
21
|
+
disableTileActions?: boolean;
|
|
21
22
|
onParticipantClick?: (event: ParticipantClickEvent) => void;
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
@@ -29,7 +29,7 @@ export function TrackRefContextIfNeeded(props) {
|
|
|
29
29
|
export const ParticipantTile =
|
|
30
30
|
/* @__PURE__ */ React.forwardRef(function ParticipantTile(_a, ref) {
|
|
31
31
|
var _b, _c;
|
|
32
|
-
var { trackRef, children, onParticipantClick, disableSpeakingIndicator } = _a, htmlProps = __rest(_a, ["trackRef", "children", "onParticipantClick", "disableSpeakingIndicator"]);
|
|
32
|
+
var { trackRef, children, onParticipantClick, disableSpeakingIndicator, disableTileActions = false } = _a, htmlProps = __rest(_a, ["trackRef", "children", "onParticipantClick", "disableSpeakingIndicator", "disableTileActions"]);
|
|
33
33
|
const scUserContext = useSCUser();
|
|
34
34
|
const trackReference = useEnsureTrackRef(trackRef);
|
|
35
35
|
const { elementProps } = useParticipantTile({
|
|
@@ -56,5 +56,5 @@ export const ParticipantTile =
|
|
|
56
56
|
trackReference.source === Track.Source.ScreenShare) ? (_jsx(_Fragment, { children: _jsx(VideoTrack, { trackRef: trackReference, onSubscriptionStatusChanged: handleSubscribe, manageSubscription: autoManageSubscription }) })) : (isTrackReference(trackReference) && (_jsx(_Fragment, { children: _jsx(AudioTrack, { trackRef: trackReference, onSubscriptionStatusChanged: handleSubscribe }) }))), _jsx("div", Object.assign({ className: "lk-participant-placeholder" }, { children: _jsx(ParticipantTileAvatar, { participant: trackReference.participant }) })), _jsxs("div", Object.assign({ className: "lk-participant-metadata" }, { children: [_jsx("div", Object.assign({ className: "lk-participant-metadata-item" }, { children: trackReference.source === Track.Source.Camera ? (_jsxs(_Fragment, { children: [isEncrypted && _jsx(LockLockedIcon, { style: { marginRight: '0.25rem' } }), _jsx(TrackMutedIndicator, { trackRef: {
|
|
57
57
|
participant: trackReference.participant,
|
|
58
58
|
source: Track.Source.Microphone
|
|
59
|
-
}, show: 'muted' }), _jsx(ParticipantName, { children: _jsx(ParticipantTileActions, {}) })] })) : (_jsxs(_Fragment, { children: [_jsx(ScreenShareIcon, { style: { marginRight: '0.25rem' } }), _jsx(ParticipantName, { children: "'s screen" })] })) })), _jsx(ConnectionQualityIndicator, { className: "lk-participant-metadata-item" })] }))] })), _jsx(FocusToggle, { trackRef: trackReference })] })) })) })));
|
|
59
|
+
}, show: 'muted' }), _jsx(ParticipantName, { children: !disableTileActions && _jsx(ParticipantTileActions, {}) })] })) : (_jsxs(_Fragment, { children: [_jsx(ScreenShareIcon, { style: { marginRight: '0.25rem' } }), _jsx(ParticipantName, { children: "'s screen" })] })) })), _jsx(ConnectionQualityIndicator, { className: "lk-participant-metadata-item" })] }))] })), _jsx(FocusToggle, { trackRef: trackReference })] })) })) })));
|
|
60
60
|
});
|
package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTileActions.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
1
|
+
import { __awaiter, __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useContext, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
@@ -8,11 +8,14 @@ import Icon from '@mui/material/Icon';
|
|
|
8
8
|
import { useSnackbar } from 'notistack';
|
|
9
9
|
import classNames from 'classnames';
|
|
10
10
|
import { Box, ClickAwayListener, Grow, IconButton, ListItemIcon, ListItemText, MenuItem, MenuList, Paper, SwipeableDrawer, useMediaQuery, useTheme } from '@mui/material';
|
|
11
|
-
import {
|
|
12
|
-
import { SCContext, SCUserContext
|
|
11
|
+
import { LiveStreamApiClient } from '@selfcommunity/api-services';
|
|
12
|
+
import { SCContext, SCUserContext } from '@selfcommunity/react-core';
|
|
13
13
|
import { BAN_ROOM_USER } from './constants';
|
|
14
14
|
import ConfirmDialog from '../../../shared/ConfirmDialog/ConfirmDialog';
|
|
15
15
|
import { useEnsureParticipant } from '@livekit/components-react';
|
|
16
|
+
import { useLiveStream } from './LiveStreamProvider';
|
|
17
|
+
import { Logger } from '@selfcommunity/utils';
|
|
18
|
+
import { SCOPE_SC_UI } from '../../../constants/Errors';
|
|
16
19
|
const PREFIX = 'SCParticipantTileActionsMenu';
|
|
17
20
|
const classes = {
|
|
18
21
|
root: `${PREFIX}-root`,
|
|
@@ -58,10 +61,9 @@ export default function ContributionActionsMenu(props) {
|
|
|
58
61
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
59
62
|
const scContext = useContext(SCContext);
|
|
60
63
|
const scUserContext = useContext(SCUserContext);
|
|
61
|
-
const scUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
62
|
-
const scRoutingContext = useSCRouting();
|
|
63
64
|
const { enqueueSnackbar } = useSnackbar();
|
|
64
65
|
const p = useEnsureParticipant(participant);
|
|
66
|
+
const { liveStream } = useLiveStream();
|
|
65
67
|
// GENERAL POPPER STATE
|
|
66
68
|
const [open, setOpen] = useState(false);
|
|
67
69
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -95,23 +97,17 @@ export default function ContributionActionsMenu(props) {
|
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
99
|
/**
|
|
98
|
-
* Perform
|
|
100
|
+
* Perform ban participant
|
|
99
101
|
*/
|
|
100
|
-
const performBanParticipant = useMemo(() => () => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (res.status >= 300) {
|
|
108
|
-
return Promise.reject(res);
|
|
109
|
-
}
|
|
110
|
-
return Promise.resolve(res.data);
|
|
111
|
-
});
|
|
112
|
-
}, [p]);
|
|
102
|
+
const performBanParticipant = useMemo(() => () => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const res = yield LiveStreamApiClient.removeUserFromRoom(liveStream.id, p.identity);
|
|
104
|
+
if (res.status >= 300) {
|
|
105
|
+
return Promise.reject(res);
|
|
106
|
+
}
|
|
107
|
+
return yield Promise.resolve(res.data);
|
|
108
|
+
}), [p]);
|
|
113
109
|
/**
|
|
114
|
-
*
|
|
110
|
+
* Handle action
|
|
115
111
|
*/
|
|
116
112
|
function handleAction(action) {
|
|
117
113
|
if (action === BAN_ROOM_USER) {
|
|
@@ -148,24 +144,29 @@ export default function ContributionActionsMenu(props) {
|
|
|
148
144
|
if (p && !isLoading && !currentActionLoading) {
|
|
149
145
|
if (currentAction === BAN_ROOM_USER) {
|
|
150
146
|
setCurrentActionLoading(BAN_ROOM_USER);
|
|
151
|
-
|
|
152
|
-
|
|
147
|
+
performBanParticipant()
|
|
148
|
+
.then(() => {
|
|
153
149
|
onBanParticipant && onBanParticipant(p);
|
|
154
150
|
performPostConfirmAction(true);
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
})
|
|
152
|
+
.catch((error) => {
|
|
157
153
|
Logger.error(SCOPE_SC_UI, error);
|
|
158
154
|
performPostConfirmAction(false);
|
|
159
|
-
|
|
155
|
+
});
|
|
160
156
|
}
|
|
161
157
|
}
|
|
162
158
|
}
|
|
163
159
|
/**
|
|
164
160
|
* Can authenticated ban a user in a room
|
|
165
161
|
*/
|
|
166
|
-
|
|
167
|
-
return
|
|
168
|
-
|
|
162
|
+
const canBanUser = useMemo(() => () => {
|
|
163
|
+
return (scUserContext.user &&
|
|
164
|
+
liveStream &&
|
|
165
|
+
p &&
|
|
166
|
+
p.identity &&
|
|
167
|
+
liveStream.host.id === scUserContext.user.id &&
|
|
168
|
+
scUserContext.user.id.toString() !== p.identity);
|
|
169
|
+
}, [scUserContext, liveStream, p]);
|
|
169
170
|
/**
|
|
170
171
|
* Renders section general
|
|
171
172
|
*/
|
|
@@ -178,6 +179,12 @@ export default function ContributionActionsMenu(props) {
|
|
|
178
179
|
function renderContent() {
|
|
179
180
|
return (_jsx(Box, { children: _jsx(MenuList, { children: renderGeneralSection() }) }));
|
|
180
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Renders component only if the logged user has actions available
|
|
184
|
+
*/
|
|
185
|
+
if (!canBanUser()) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
181
188
|
/**
|
|
182
189
|
* Renders component
|
|
183
190
|
*/
|
package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTileAvatar.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SCUserType } from '@selfcommunity/types';
|
|
2
|
-
export interface
|
|
2
|
+
export interface ParticipantTileAvatarProps {
|
|
3
3
|
className?: string;
|
|
4
4
|
/**
|
|
5
5
|
* User Object
|
|
@@ -12,4 +12,4 @@ export interface ParticipantTileProps {
|
|
|
12
12
|
*/
|
|
13
13
|
participant?: any;
|
|
14
14
|
}
|
|
15
|
-
export default function
|
|
15
|
+
export default function ParticipantTileAvatar(inProps: ParticipantTileAvatarProps): JSX.Element;
|
package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTileAvatar.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from 'react';
|
|
3
4
|
import { styled } from '@mui/material/styles';
|
|
4
5
|
import { useThemeProps } from '@mui/system';
|
|
5
6
|
import { Box } from '@mui/material';
|
|
@@ -22,7 +23,7 @@ const Root = styled(Box, {
|
|
|
22
23
|
height: 100
|
|
23
24
|
}
|
|
24
25
|
}));
|
|
25
|
-
export default function
|
|
26
|
+
export default function ParticipantTileAvatar(inProps) {
|
|
26
27
|
// PROPS
|
|
27
28
|
const props = useThemeProps({
|
|
28
29
|
props: inProps,
|
|
@@ -31,5 +32,15 @@ export default function UserAvatar(inProps) {
|
|
|
31
32
|
const { className, user, participant } = props, rest = __rest(props, ["className", "user", "participant"]);
|
|
32
33
|
// CONTEXT
|
|
33
34
|
const scContext = useSCContext();
|
|
34
|
-
|
|
35
|
+
// AVATAR
|
|
36
|
+
const avatar = useMemo(() => {
|
|
37
|
+
if (user) {
|
|
38
|
+
return _jsx("img", { src: `${user.avatar}` });
|
|
39
|
+
}
|
|
40
|
+
if (participant) {
|
|
41
|
+
return _jsx("img", { src: `${scContext.settings.portal}/api/v2/avatar/${participant.identity}` });
|
|
42
|
+
}
|
|
43
|
+
return _jsx(ParticipantPlaceholder, {});
|
|
44
|
+
}, [user, participant]);
|
|
45
|
+
return (_jsx(Root, Object.assign({ className: classNames(className, classes.root) }, rest, { children: avatar })));
|
|
35
46
|
}
|
|
@@ -2,7 +2,6 @@ import type { CreateLocalTracksOptions, LocalAudioTrack, LocalTrack, LocalVideoT
|
|
|
2
2
|
import { Track } from 'livekit-client';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import type { LocalUserChoices } from '@livekit/components-core';
|
|
5
|
-
import { SCLiveStreamType } from '@selfcommunity/types';
|
|
6
5
|
/**
|
|
7
6
|
* Props for the PreJoin component.
|
|
8
7
|
* @public
|
|
@@ -15,11 +14,6 @@ export interface PreJoinProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
|
|
|
15
14
|
*/
|
|
16
15
|
onValidate?: (values: LocalUserChoices) => boolean;
|
|
17
16
|
onError?: (error: Error) => void;
|
|
18
|
-
/**
|
|
19
|
-
* Livestream Object
|
|
20
|
-
* @default null
|
|
21
|
-
*/
|
|
22
|
-
liveStream?: SCLiveStreamType;
|
|
23
17
|
/** Prefill the input form with initial values. */
|
|
24
18
|
defaults?: Partial<LocalUserChoices>;
|
|
25
19
|
/** Display a debug window for your convenience. */
|
|
@@ -58,4 +52,4 @@ export declare function usePreviewDevice<T extends LocalVideoTrack | LocalAudioT
|
|
|
58
52
|
* ```
|
|
59
53
|
* @public
|
|
60
54
|
*/
|
|
61
|
-
export declare function PreJoin({
|
|
55
|
+
export declare function PreJoin({ defaults, onValidate, onSubmit, onError, debug, joinLabel, micLabel, camLabel, userLabel, persistUserChoices, ...htmlProps }: PreJoinProps): JSX.Element;
|