Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVE] Change header based on room type #20612

Merged
merged 6 commits into from
Feb 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions client/views/room/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ import { useLayout } from '../../../contexts/LayoutContext';
import Burger from './Burger';
import MarkdownText from '../../../components/MarkdownText';
import { roomTypes } from '../../../../app/utils';
import { useUserRoom } from '../../../contexts/UserContext';
import { useUserRoom, useUserId } from '../../../contexts/UserContext';
import { useUserData } from '../../../hooks/useUserData';

export default React.memo(({ room }) => {
const { isEmbedded, showTopNavbarEmbeddedLayout } = useLayout();
if (isEmbedded && !showTopNavbarEmbeddedLayout) {
return null;
}
return <RoomHeader room={room}/>;

if (room.t === 'd' && room.uids.length < 3) {
return <DirectRoomHeader room={room} />;
}

return <RoomHeader room={room} topic={room.topic} />;
});

const HeaderIcon = ({ room }) => {
Expand Down Expand Up @@ -47,8 +53,15 @@ const RoomTitle = ({ room }) => {
</Breadcrumbs>;
};

const DirectRoomHeader = ({ room }) => {
const userId = useUserId();
const directUserId = room.uids.filter((uid) => uid !== userId).shift();
const directUserData = useUserData(directUserId);

return <RoomHeader room={room} topic={directUserData?.statusText} />;
};

const RoomHeader = ({ room }) => {
const RoomHeader = ({ room, topic }) => {
const { isMobile } = useLayout();
const avatar = <RoomAvatar room={room}/>;

Expand All @@ -65,7 +78,7 @@ const RoomHeader = ({ room }) => {
<Translate room={room} />
</Header.Content.Row>
<Header.Content.Row>
<Header.Subtitle>{room.topic && <MarkdownText withRichContent={false} content={room.topic}/>}</Header.Subtitle>
<Header.Subtitle>{topic && <MarkdownText withRichContent={false} content={topic}/>}</Header.Subtitle>
</Header.Content.Row>
</Header.Content>
<Header.ToolBox>
Expand Down