diff --git a/src/components/views/dialogs/ShareDialog.tsx b/src/components/views/dialogs/ShareDialog.tsx
index 06be765df56..a26e3068cc5 100644
--- a/src/components/views/dialogs/ShareDialog.tsx
+++ b/src/components/views/dialogs/ShareDialog.tsx
@@ -60,14 +60,29 @@ const socials = [
url: (url: string) => `mailto:?body=${url}`,
},
];
-
+// add doc strings to BaseProps
interface BaseProps {
+ /**
+ * A function that is called when the dialog is dismissed
+ */
onFinished(): void;
+ /**
+ * An optional string to use as the dialog title.
+ * If not provided, an appropriate title for the target type will be used.
+ */
customTitle?: string;
+ /**
+ * An optional string to use as the dialog subtitle
+ */
subtitle?: string;
}
interface Props extends BaseProps {
+ /**
+ * The target to link to.
+ * This can be a Room, User, RoomMember, or MatrixEvent or an already computed URL.
+ * A matrix.to link will be generated out of it if its no already a computed url.
+ */
target: Room | User | RoomMember | URL;
permalinkCreator?: RoomPermalinkCreator;
}
diff --git a/src/components/views/rooms/RoomHeader.tsx b/src/components/views/rooms/RoomHeader.tsx
index 2fa194fcfbd..8ca26ebcdea 100644
--- a/src/components/views/rooms/RoomHeader.tsx
+++ b/src/components/views/rooms/RoomHeader.tsx
@@ -83,6 +83,7 @@ export default function RoomHeader({
toggleCallMaximized: toggleCall,
isViewingCall,
generateCallLink,
+ canGenerateCallLink,
isConnectedToCall,
hasActiveCallSession,
callOptions,
@@ -124,15 +125,16 @@ export default function RoomHeader({
const videoClick = useCallback((ev) => videoCallClick(ev, callOptions[0]), [callOptions, videoCallClick]);
const shareClick = useCallback(() => {
- const target = generateCallLink ? generateCallLink() : undefined;
- if (target) {
+ try {
+ // generateCallLink throws if the permissions are not met
+ const target = generateCallLink();
Modal.createDialog(ShareDialog, {
target,
customTitle: _t("share|share_call"),
subtitle: _t("share|share_call_subtitle"),
});
- } else {
- logger.error("Could not generate call link.");
+ } catch (e) {
+ logger.error("Could not generate call link.", e);
}
}, [generateCallLink]);
@@ -333,7 +335,7 @@ export default function RoomHeader({
);
})}
- {isViewingCall && generateCallLink && createExternalLinkButton}
+ {isViewingCall && canGenerateCallLink && createExternalLinkButton}
{((isConnectedToCall && isViewingCall) || isVideoRoom(room)) && }
{hasActiveCallSession && !isConnectedToCall && !isViewingCall ? (
diff --git a/src/hooks/room/useRoomCall.ts b/src/hooks/room/useRoomCall.ts
index df445e6e5a2..92f350087fb 100644
--- a/src/hooks/room/useRoomCall.ts
+++ b/src/hooks/room/useRoomCall.ts
@@ -80,7 +80,8 @@ export const useRoomCall = (
videoCallClick(evt: React.MouseEvent | undefined, selectedType: PlatformCallType): void;
toggleCallMaximized: () => void;
isViewingCall: boolean;
- generateCallLink: (() => URL) | undefined;
+ generateCallLink: () => URL;
+ canGenerateCallLink: boolean;
isConnectedToCall: boolean;
hasActiveCallSession: boolean;
callOptions: PlatformCallType[];
@@ -271,7 +272,8 @@ export const useRoomCall = (
}, [isViewingCall, room.roomId]);
const generateCallLink = useCallback(() => {
- // Should never happen, because the hook only passes generateCallLink if externalSpaUrl is set.
+ if (!canJoinWithoutInvite)
+ throw new Error("Cannot create link for room that users can not join without invite.");
if (!guestSpaUrl) throw new Error("No guest SPA url for external links provided.");
const url = new URL(guestSpaUrl);
url.pathname = "/room/";
@@ -288,7 +290,7 @@ export const useRoomCall = (
logger.info("Generated element call external url:", url);
return url;
- }, [guestSpaUrl, room]);
+ }, [canJoinWithoutInvite, guestSpaUrl, room]);
/**
* We've gone through all the steps
*/
@@ -299,7 +301,8 @@ export const useRoomCall = (
videoCallClick,
toggleCallMaximized: toggleCallMaximized,
isViewingCall: isViewingCall,
- generateCallLink: guestSpaUrl && canJoinWithoutInvite ? generateCallLink : undefined,
+ generateCallLink,
+ canGenerateCallLink: guestSpaUrl !== undefined && canJoinWithoutInvite,
isConnectedToCall: isConnectedToCall,
hasActiveCallSession: hasActiveCallSession,
callOptions,