Chat: Fix height with folder tags (#6262)
This commit is contained in:
parent
cb6b92f64e
commit
73d5804a2c
@ -336,8 +336,11 @@
|
|||||||
|
|
||||||
&.has-tags {
|
&.has-tags {
|
||||||
line-height: 1.375rem;
|
line-height: 1.375rem;
|
||||||
.info-row {
|
|
||||||
height: 1.25rem;
|
.ChatBadge {
|
||||||
|
min-width: 1.375rem;
|
||||||
|
height: 1.375rem;
|
||||||
|
line-height: 1.5rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import type { ChatAnimationTypes } from './hooks';
|
|||||||
import { MAIN_THREAD_ID } from '../../../api/types';
|
import { MAIN_THREAD_ID } from '../../../api/types';
|
||||||
import { StoryViewerOrigin } from '../../../types';
|
import { StoryViewerOrigin } from '../../../types';
|
||||||
|
|
||||||
import { UNMUTE_TIMESTAMP } from '../../../config';
|
import { ALL_FOLDER_ID, UNMUTE_TIMESTAMP } from '../../../config';
|
||||||
import {
|
import {
|
||||||
groupStatefulContent,
|
groupStatefulContent,
|
||||||
isUserOnline,
|
isUserOnline,
|
||||||
@ -124,10 +124,9 @@ type StateProps = {
|
|||||||
currentUserId: string;
|
currentUserId: string;
|
||||||
isSynced?: boolean;
|
isSynced?: boolean;
|
||||||
isAccountFrozen?: boolean;
|
isAccountFrozen?: boolean;
|
||||||
folderIds?: number[];
|
chatFolderIds?: number[];
|
||||||
orderedIds?: number[];
|
orderedFolderIds?: number[];
|
||||||
chatFoldersById?: Record<number, ApiChatFolder>;
|
chatFoldersById?: Record<number, ApiChatFolder>;
|
||||||
activeChatFolder?: number;
|
|
||||||
areTagsEnabled?: boolean;
|
areTagsEnabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -168,10 +167,9 @@ const Chat: FC<OwnProps & StateProps> = ({
|
|||||||
isSynced,
|
isSynced,
|
||||||
onDragEnter,
|
onDragEnter,
|
||||||
isAccountFrozen,
|
isAccountFrozen,
|
||||||
folderIds,
|
chatFolderIds,
|
||||||
orderedIds,
|
orderedFolderIds,
|
||||||
chatFoldersById,
|
chatFoldersById,
|
||||||
activeChatFolder,
|
|
||||||
areTagsEnabled,
|
areTagsEnabled,
|
||||||
withTags,
|
withTags,
|
||||||
}) => {
|
}) => {
|
||||||
@ -202,7 +200,23 @@ const Chat: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
useEnsureMessage(isSavedDialog ? currentUserId : chatId, lastMessageId, lastMessage);
|
useEnsureMessage(isSavedDialog ? currentUserId : chatId, lastMessageId, lastMessage);
|
||||||
|
|
||||||
const shouldRenderTags = areTagsEnabled && withTags && folderIds && folderIds.length > 1;
|
const tagFolderIds = useMemo(() => {
|
||||||
|
const chatFolderIdsSet = new Set(chatFolderIds);
|
||||||
|
|
||||||
|
return orderedFolderIds?.filter((id) => {
|
||||||
|
if (!chatFolderIdsSet.has(id)) return undefined;
|
||||||
|
|
||||||
|
const isActive = id === folderId;
|
||||||
|
const isAll = id === ALL_FOLDER_ID;
|
||||||
|
|
||||||
|
const folder = chatFoldersById?.[id];
|
||||||
|
const hasColor = folder?.color !== undefined && folder.color !== -1;
|
||||||
|
|
||||||
|
return !isActive && !isAll && hasColor;
|
||||||
|
});
|
||||||
|
}, [orderedFolderIds, folderId, chatFoldersById, chatFolderIds]);
|
||||||
|
|
||||||
|
const shouldRenderTags = areTagsEnabled && withTags && Boolean(tagFolderIds?.length);
|
||||||
|
|
||||||
const { renderSubtitle, ref } = useChatListEntry({
|
const { renderSubtitle, ref } = useChatListEntry({
|
||||||
chat,
|
chat,
|
||||||
@ -372,7 +386,7 @@ const Chat: FC<OwnProps & StateProps> = ({
|
|||||||
isSelected && 'selected',
|
isSelected && 'selected',
|
||||||
isSelectedForum && 'selected-forum',
|
isSelectedForum && 'selected-forum',
|
||||||
isPreview && 'standalone',
|
isPreview && 'standalone',
|
||||||
shouldRenderTags && 'chat-item-with-tags',
|
areTagsEnabled && withTags && 'chat-item-with-tags',
|
||||||
className,
|
className,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -420,7 +434,7 @@ const Chat: FC<OwnProps & StateProps> = ({
|
|||||||
<ChatCallStatus isMobile={isMobile} isSelected={isSelected} isActive={withInterfaceAnimations} />
|
<ChatCallStatus isMobile={isMobile} isSelected={isSelected} isActive={withInterfaceAnimations} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className={buildClassName('info', shouldRenderTags && 'has-tags')}>
|
<div className={buildClassName('info', areTagsEnabled && withTags && 'has-tags')}>
|
||||||
<div className="info-row">
|
<div className="info-row">
|
||||||
<FullNameTitle
|
<FullNameTitle
|
||||||
peer={isMonoforum ? monoforumChannel! : peer}
|
peer={isMonoforum ? monoforumChannel! : peer}
|
||||||
@ -458,10 +472,8 @@ const Chat: FC<OwnProps & StateProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
{shouldRenderTags && (
|
{shouldRenderTags && (
|
||||||
<ChatTags
|
<ChatTags
|
||||||
folderIds={folderIds}
|
orderedFolderIds={tagFolderIds}
|
||||||
orderedIds={orderedIds}
|
|
||||||
chatFoldersById={chatFoldersById}
|
chatFoldersById={chatFoldersById}
|
||||||
activeChatFolder={activeChatFolder}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@ -506,7 +518,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
} as Complete<StateProps>;
|
} as Complete<StateProps>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const folderIds = getChatFolderIds(chatId);
|
const chatFolderIds = getChatFolderIds(chatId);
|
||||||
const { areTagsEnabled } = global.chatFolders;
|
const { areTagsEnabled } = global.chatFolders;
|
||||||
const isPremium = selectIsCurrentUserPremium(global);
|
const isPremium = selectIsCurrentUserPremium(global);
|
||||||
|
|
||||||
@ -542,8 +554,6 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
|
|
||||||
const monoforumChannel = selectMonoforumChannel(global, chatId);
|
const monoforumChannel = selectMonoforumChannel(global, chatId);
|
||||||
|
|
||||||
const activeChatFolder = selectTabState(global).activeChatFolder;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
chat,
|
chat,
|
||||||
isMuted: getIsChatMuted(chat, selectNotifyDefaults(global), selectNotifyException(global, chat.id)),
|
isMuted: getIsChatMuted(chat, selectNotifyDefaults(global), selectNotifyException(global, chat.id)),
|
||||||
@ -569,9 +579,8 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
lastMessageStory,
|
lastMessageStory,
|
||||||
isAccountFrozen,
|
isAccountFrozen,
|
||||||
monoforumChannel,
|
monoforumChannel,
|
||||||
folderIds,
|
chatFolderIds,
|
||||||
orderedIds: global.chatFolders.orderedIds,
|
orderedFolderIds: global.chatFolders.orderedIds,
|
||||||
activeChatFolder,
|
|
||||||
chatFoldersById: global.chatFolders.byId,
|
chatFoldersById: global.chatFolders.byId,
|
||||||
areTagsEnabled: areTagsEnabled && isPremium,
|
areTagsEnabled: areTagsEnabled && isPremium,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
.wrapper {
|
.wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 0.25rem;
|
gap: 0.25rem;
|
||||||
padding-top: 0.25rem;
|
height: 0.875rem;
|
||||||
|
margin-top: 0.125rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag {
|
.tag {
|
||||||
@ -16,12 +17,12 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
min-width: 1.5rem;
|
min-width: 1.5rem;
|
||||||
padding: 0.0625rem 0.25rem;
|
padding: 0 0.25rem;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
|
|
||||||
font-size: 0.625rem;
|
font-size: 0.6875rem;
|
||||||
font-weight: var(--font-weight-medium);
|
font-weight: var(--font-weight-medium);
|
||||||
line-height: 0.75rem;
|
line-height: 1;
|
||||||
color: var(--accent-color);
|
color: var(--accent-color);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
import { memo, useMemo } from '../../../lib/teact/teact';
|
import { memo } from '../../../lib/teact/teact';
|
||||||
|
|
||||||
import type { ApiChatFolder } from '../../../api/types';
|
import type { ApiChatFolder } from '../../../api/types';
|
||||||
|
|
||||||
import { ALL_FOLDER_ID } from '../../../config';
|
|
||||||
import buildClassName from '../../../util/buildClassName';
|
import buildClassName from '../../../util/buildClassName';
|
||||||
import { getApiPeerColorClass } from '../../common/helpers/peerColor';
|
import { getApiPeerColorClass } from '../../common/helpers/peerColor';
|
||||||
import { renderTextWithEntities } from '../../common/helpers/renderTextWithEntities';
|
import { renderTextWithEntities } from '../../common/helpers/renderTextWithEntities';
|
||||||
@ -12,30 +11,17 @@ import styles from './ChatTags.module.scss';
|
|||||||
const MAX_VISIBLE_TAGS = 3;
|
const MAX_VISIBLE_TAGS = 3;
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
folderIds?: number[];
|
orderedFolderIds?: number[];
|
||||||
orderedIds?: number[];
|
|
||||||
chatFoldersById?: Record<number, ApiChatFolder>;
|
chatFoldersById?: Record<number, ApiChatFolder>;
|
||||||
activeChatFolder?: number;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const ChatTags = ({
|
const ChatTags = ({
|
||||||
folderIds,
|
orderedFolderIds,
|
||||||
orderedIds,
|
|
||||||
chatFoldersById,
|
chatFoldersById,
|
||||||
activeChatFolder,
|
|
||||||
}: OwnProps) => {
|
}: OwnProps) => {
|
||||||
const activeFolderId = activeChatFolder !== undefined && orderedIds ? orderedIds[activeChatFolder] : undefined;
|
if (!orderedFolderIds) {
|
||||||
|
return undefined;
|
||||||
const orderedFolderIds = useMemo(() => orderedIds?.filter((id) => {
|
}
|
||||||
const isFolder = folderIds?.includes(id);
|
|
||||||
const isActive = id === activeFolderId;
|
|
||||||
const isAll = id === ALL_FOLDER_ID;
|
|
||||||
|
|
||||||
const folder = chatFoldersById?.[id];
|
|
||||||
const hasColor = folder?.color !== undefined && folder.color !== -1;
|
|
||||||
|
|
||||||
return isFolder && !isActive && !isAll && hasColor;
|
|
||||||
}) || [], [orderedIds, folderIds, activeFolderId, chatFoldersById]);
|
|
||||||
|
|
||||||
const visibleFolderIds = orderedFolderIds.slice(0, MAX_VISIBLE_TAGS);
|
const visibleFolderIds = orderedFolderIds.slice(0, MAX_VISIBLE_TAGS);
|
||||||
const remainingCount = orderedFolderIds.length - visibleFolderIds.length;
|
const remainingCount = orderedFolderIds.length - visibleFolderIds.length;
|
||||||
|
|||||||
@ -225,7 +225,9 @@
|
|||||||
|
|
||||||
&.chat-item-with-tags {
|
&.chat-item-with-tags {
|
||||||
.ListItem-button {
|
.ListItem-button {
|
||||||
|
height: 72px;
|
||||||
padding: 0.375rem 0.5625rem;
|
padding: 0.375rem 0.5625rem;
|
||||||
|
align-items: flex-start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user