Prefer assertion

pull/24536/head
Tasso Evangelista 4 years ago
parent a6d2ec2899
commit 08e8a58fcb
No known key found for this signature in database
GPG Key ID: 9EA06BE6FD613A03
  1. 2
      client/views/room/threads/ThreadComponent.tsx
  2. 8
      lib/rooms/coordinator.ts

@ -63,7 +63,7 @@ const ThreadComponent: FC<{
onClickBack: (e: unknown) => void;
}> = ({ mid, jump, room, onClickBack }) => {
const subscription = useUserSubscription(room._id, subscriptionFields);
const channelRoute = useRoute(roomCoordinator.getRoomTypeConfig(room.t)?.route?.name as string);
const channelRoute = useRoute(roomCoordinator.getRoomTypeConfig(room.t).route.name);
const threadMessage = useThreadMessage(mid);
const openUserInfo = useTabBarOpenUserInfo();

@ -108,8 +108,12 @@ export abstract class RoomCoordinator {
return undefined;
}
getRoomTypeConfig(identifier: string): IRoomTypeConfig | undefined {
return this.roomTypes[identifier]?.config;
getRoomTypeConfig(identifier: string): IRoomTypeConfig {
if (!this.roomTypes[identifier]) {
throw new Error(`Room type with identifier ${identifier} does not exist.`);
}
return this.roomTypes[identifier].config;
}
getRouteLink(roomType: string, subData: RoomIdentification): string | false {

Loading…
Cancel
Save