@@ -117,6 +117,7 @@ import { WidgetType } from "../../widgets/WidgetType";
117
117
import WidgetUtils from "../../utils/WidgetUtils" ;
118
118
import { shouldEncryptRoomWithSingle3rdPartyInvite } from "../../utils/room/shouldEncryptRoomWithSingle3rdPartyInvite" ;
119
119
import { WaitingForThirdPartyRoomView } from "./WaitingForThirdPartyRoomView" ;
120
+ import { isNotUndefined } from "../../Typeguards" ;
120
121
121
122
const DEBUG = false ;
122
123
const PREVENT_MULTIPLE_JITSI_WITHIN = 30_000 ;
@@ -809,7 +810,21 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
809
810
return this . state . room ?. roomId ?? this . state . roomId ;
810
811
} ;
811
812
812
- private getPermalinkCreatorForRoom ( room : Room ) : RoomPermalinkCreator {
813
+ private getPermalinkCreatorForRoom ( ) : RoomPermalinkCreator {
814
+ const { room, roomId } = this . state ;
815
+
816
+ // If room is undefined, attempt to use the roomId to create and store a permalinkCreator.
817
+ // Throw an error if we can not find a roomId in state.
818
+ if ( room === undefined ) {
819
+ if ( isNotUndefined ( roomId ) ) {
820
+ const permalinkCreator = new RoomPermalinkCreator ( null , roomId ) ;
821
+ this . permalinkCreators [ roomId ] = permalinkCreator ;
822
+ return permalinkCreator ;
823
+ } else {
824
+ throw new Error ( "Cannot get a permalink creator without a roomId" ) ;
825
+ }
826
+ }
827
+
813
828
if ( this . permalinkCreators [ room . roomId ] ) return this . permalinkCreators [ room . roomId ] ;
814
829
815
830
this . permalinkCreators [ room . roomId ] = new RoomPermalinkCreator ( room ) ;
@@ -1096,14 +1111,19 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
1096
1111
payload . data . threadId ,
1097
1112
) ;
1098
1113
break ;
1099
- case "picture_snapshot" :
1100
- ContentMessages . sharedInstance ( ) . sendContentListToRoom (
1101
- [ payload . file ] ,
1102
- this . getRoomId ( ) ,
1103
- undefined ,
1104
- this . context . client ,
1105
- ) ;
1114
+ case "picture_snapshot" : {
1115
+ const roomId = this . getRoomId ( ) ;
1116
+ if ( isNotUndefined ( roomId ) ) {
1117
+ ContentMessages . sharedInstance ( ) . sendContentListToRoom (
1118
+ [ payload . file ] ,
1119
+ roomId ,
1120
+ undefined ,
1121
+ this . context . client ,
1122
+ ) ;
1123
+ }
1124
+
1106
1125
break ;
1126
+ }
1107
1127
case "notifier_enabled" :
1108
1128
case Action . UploadStarted :
1109
1129
case Action . UploadFinished :
@@ -1552,12 +1572,16 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
1552
1572
} else {
1553
1573
Promise . resolve ( ) . then ( ( ) => {
1554
1574
const signUrl = this . props . threepidInvite ?. signUrl ;
1555
- dis . dispatch < JoinRoomPayload > ( {
1556
- action : Action . JoinRoom ,
1557
- roomId : this . getRoomId ( ) ,
1558
- opts : { inviteSignUrl : signUrl } ,
1559
- metricsTrigger : this . state . room ?. getMyMembership ( ) === "invite" ? "Invite" : "RoomPreview" ,
1560
- } ) ;
1575
+ const roomId = this . getRoomId ( ) ;
1576
+ if ( isNotUndefined ( roomId ) ) {
1577
+ dis . dispatch < JoinRoomPayload > ( {
1578
+ action : Action . JoinRoom ,
1579
+ roomId,
1580
+ opts : { inviteSignUrl : signUrl } ,
1581
+ metricsTrigger : this . state . room ?. getMyMembership ( ) === "invite" ? "Invite" : "RoomPreview" ,
1582
+ } ) ;
1583
+ }
1584
+
1561
1585
return Promise . resolve ( ) ;
1562
1586
} ) ;
1563
1587
}
@@ -1920,7 +1944,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
1920
1944
}
1921
1945
1922
1946
private get permalinkCreator ( ) : RoomPermalinkCreator {
1923
- return this . getPermalinkCreatorForRoom ( this . state . room ) ;
1947
+ return this . getPermalinkCreatorForRoom ( ) ;
1924
1948
}
1925
1949
1926
1950
private renderLocalRoomCreateLoader ( localRoom : LocalRoom ) : ReactNode {
0 commit comments