Skip to content

Commit 08e8a58

Browse files
committed
Prefer assertion
1 parent a6d2ec2 commit 08e8a58

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

client/views/room/threads/ThreadComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const ThreadComponent: FC<{
6363
onClickBack: (e: unknown) => void;
6464
}> = ({ mid, jump, room, onClickBack }) => {
6565
const subscription = useUserSubscription(room._id, subscriptionFields);
66-
const channelRoute = useRoute(roomCoordinator.getRoomTypeConfig(room.t)?.route?.name as string);
66+
const channelRoute = useRoute(roomCoordinator.getRoomTypeConfig(room.t).route.name);
6767
const threadMessage = useThreadMessage(mid);
6868

6969
const openUserInfo = useTabBarOpenUserInfo();

lib/rooms/coordinator.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,12 @@ export abstract class RoomCoordinator {
108108
return undefined;
109109
}
110110

111-
getRoomTypeConfig(identifier: string): IRoomTypeConfig | undefined {
112-
return this.roomTypes[identifier]?.config;
111+
getRoomTypeConfig(identifier: string): IRoomTypeConfig {
112+
if (!this.roomTypes[identifier]) {
113+
throw new Error(`Room type with identifier ${identifier} does not exist.`);
114+
}
115+
116+
return this.roomTypes[identifier].config;
113117
}
114118

115119
getRouteLink(roomType: string, subData: RoomIdentification): string | false {

0 commit comments

Comments
 (0)