Skip to content

Commit

Permalink
review: ad condition to tag click when cannot redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
juliajforesti committed Oct 7, 2024
1 parent 0037f04 commit e04123a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions apps/meteor/client/views/room/Header/ParentRoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ type ParentRoomProps = {
room: Pick<IRoom, '_id' | 't' | 'name' | 'fname' | 'prid' | 'u'>;
};

const hasSubscription = (room: ParentRoomProps['room']): boolean => roomCoordinator.getRoomDirectives(room.t).hasSubscription(room._id);
const ParentRoom = ({ room }: ParentRoomProps): ReactElement => {
const icon = useRoomIcon(room);

const handleRedirect = (): void => {
if (!roomCoordinator.getRoomDirectives(room.t).hasSubscription(room._id)) {
return;
}
roomCoordinator.openRouteLink(room.t, { rid: room._id, ...room });
};
const handleRedirect = hasSubscription(room)
? (): void => {
roomCoordinator.openRouteLink(room.t, { rid: room._id, ...room });
}
: undefined;

return (
<HeaderTag
role='button'
tabIndex={0}
onKeyDown={(e) => (e.code === 'Space' || e.code === 'Enter') && handleRedirect()}
onKeyDown={(e) => (e.code === 'Space' || e.code === 'Enter') && handleRedirect?.()}
onClick={handleRedirect}
>
<HeaderTagIcon icon={icon} />
Expand Down
14 changes: 7 additions & 7 deletions apps/meteor/client/views/room/HeaderV2/ParentRoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ type ParentRoomProps = {
room: Pick<IRoom, '_id' | 't' | 'name' | 'fname' | 'prid' | 'u'>;
};

const hasSubscription = (room: ParentRoomProps['room']): boolean => roomCoordinator.getRoomDirectives(room.t).hasSubscription(room._id);
const ParentRoom = ({ room }: ParentRoomProps) => {
const icon = useRoomIcon(room);

const handleRedirect = (): void => {
if (!roomCoordinator.getRoomDirectives(room.t).hasSubscription(room._id)) {
return;
}
roomCoordinator.openRouteLink(room.t, { rid: room._id, ...room });
};
const handleRedirect = hasSubscription(room)
? (): void => {
roomCoordinator.openRouteLink(room.t, { rid: room._id, ...room });
}
: undefined;

return (
<HeaderTag
role='button'
tabIndex={0}
onKeyDown={(e) => (e.code === 'Space' || e.code === 'Enter') && handleRedirect()}
onKeyDown={(e) => (e.code === 'Space' || e.code === 'Enter') && handleRedirect?.()}
onClick={handleRedirect}
>
<HeaderTagIcon icon={icon} />
Expand Down

0 comments on commit e04123a

Please sign in to comment.