Add embed mode

2db23e4110
from postmessage_ptt branch done in a slightly nicer way
This commit is contained in:
David Baker 2022-06-28 15:08:14 +01:00
parent 5ced94755b
commit 7dc6fb27ea
4 changed files with 24 additions and 4 deletions

View file

@ -77,9 +77,23 @@ export function RoomHeaderInfo({ roomName, avatarUrl }) {
); );
} }
export function RoomSetupHeaderInfo({ roomName, avatarUrl, ...rest }) { export function RoomSetupHeaderInfo({
roomName,
avatarUrl,
isEmbedded,
...rest
}) {
const ref = useRef(); const ref = useRef();
const { buttonProps } = useButton(rest, ref); const { buttonProps } = useButton(rest, ref);
if (isEmbedded) {
return (
<div className={styles.backButton} ref={ref} {...buttonProps}>
<RoomHeaderInfo roomName={roomName} avatarUrl={avatarUrl} />
</div>
);
}
return ( return (
<button className={styles.backButton} ref={ref} {...buttonProps}> <button className={styles.backButton} ref={ref} {...buttonProps}>
<ArrowLeftIcon width={16} height={16} /> <ArrowLeftIcon width={16} height={16} />

View file

@ -30,6 +30,7 @@ import { useLocationNavigation } from "../useLocationNavigation";
export function GroupCallView({ export function GroupCallView({
client, client,
isPasswordlessUser, isPasswordlessUser,
isEmbedded,
roomId, roomId,
groupCall, groupCall,
}) { }) {
@ -92,6 +93,7 @@ export function GroupCallView({
participants={participants} participants={participants}
userMediaFeeds={userMediaFeeds} userMediaFeeds={userMediaFeeds}
onLeave={onLeave} onLeave={onLeave}
isEmbedded={isEmbedded}
/> />
); );
} else { } else {

View file

@ -93,6 +93,7 @@ interface Props {
participants: RoomMember[]; participants: RoomMember[];
userMediaFeeds: CallFeed[]; userMediaFeeds: CallFeed[];
onLeave: () => void; onLeave: () => void;
isEmbedded: boolean;
} }
export const PTTCallView: React.FC<Props> = ({ export const PTTCallView: React.FC<Props> = ({
@ -104,6 +105,7 @@ export const PTTCallView: React.FC<Props> = ({
participants, participants,
userMediaFeeds, userMediaFeeds,
onLeave, onLeave,
isEmbedded,
}) => { }) => {
const { modalState: inviteModalState, modalProps: inviteModalProps } = const { modalState: inviteModalState, modalProps: inviteModalProps } =
useModalTriggerState(); useModalTriggerState();
@ -176,6 +178,7 @@ export const PTTCallView: React.FC<Props> = ({
roomName={roomName} roomName={roomName}
avatarUrl={avatarUrl} avatarUrl={avatarUrl}
onPress={onLeave} onPress={onLeave}
isEmbedded={isEmbedded}
/> />
</LeftNav> </LeftNav>
<RightNav /> <RightNav />
@ -203,7 +206,7 @@ export const PTTCallView: React.FC<Props> = ({
feedbackModalState={feedbackModalState} feedbackModalState={feedbackModalState}
feedbackModalProps={feedbackModalProps} feedbackModalProps={feedbackModalProps}
/> />
<HangupButton onPress={onLeave} /> {!isEmbedded && <HangupButton onPress={onLeave} />}
<InviteButton onPress={() => inviteModalState.open()} /> <InviteButton onPress={() => inviteModalState.open()} />
</div> </div>

View file

@ -29,9 +29,9 @@ export function RoomPage() {
const { roomId: maybeRoomId } = useParams(); const { roomId: maybeRoomId } = useParams();
const { hash, search } = useLocation(); const { hash, search } = useLocation();
const [viaServers] = useMemo(() => { const [viaServers, isEmbedded] = useMemo(() => {
const params = new URLSearchParams(search); const params = new URLSearchParams(search);
return [params.getAll("via")]; return [params.getAll("via"), params.get("embed") !== null];
}, [search]); }, [search]);
const roomId = (maybeRoomId || hash || "").toLowerCase(); const roomId = (maybeRoomId || hash || "").toLowerCase();
@ -56,6 +56,7 @@ export function RoomPage() {
roomId={roomId} roomId={roomId}
groupCall={groupCall} groupCall={groupCall}
isPasswordlessUser={isPasswordlessUser} isPasswordlessUser={isPasswordlessUser}
isEmbedded={isEmbedded}
/> />
)} )}
</GroupCallLoader> </GroupCallLoader>