Chat List: Allow showing chats with no messages

This commit is contained in:
Alexander Zinchuk 2022-09-16 18:28:51 +02:00
parent 4b4b9281a7
commit 3591aea8d5
3 changed files with 13 additions and 7 deletions

View File

@ -29,6 +29,10 @@
}
}
&:last-of-type {
padding-bottom: 0.5rem;
}
@media (max-width: 600px) {
&.selected {
--background-color: var(--color-chat-hover) !important;

View File

@ -135,7 +135,7 @@ const Chat: FC<OwnProps & StateProps> = ({
const { lastMessage, typingStatus } = chat || {};
const isAction = lastMessage && isActionMessage(lastMessage);
useEnsureMessage(chatId, isAction ? lastMessage!.replyToMessageId : undefined, actionTargetMessage);
useEnsureMessage(chatId, isAction ? lastMessage.replyToMessageId : undefined, actionTargetMessage);
const mediaThumbnail = lastMessage && !getMessageSticker(lastMessage)
? getMessageMediaThumbDataUri(lastMessage)
@ -288,7 +288,7 @@ const Chat: FC<OwnProps & StateProps> = ({
<span className="colon">:</span>
</>
)}
{renderSummary(lang, lastMessage!, observeIntersection, mediaBlobUrl || mediaThumbnail, isRoundVideo)}
{renderSummary(lang, lastMessage, observeIntersection, mediaBlobUrl || mediaThumbnail, isRoundVideo)}
</p>
);
}
@ -391,13 +391,13 @@ function renderSummary(
export default memo(withGlobal<OwnProps>(
(global, { chatId }): StateProps => {
const chat = selectChat(global, chatId);
if (!chat || !chat.lastMessage) {
if (!chat) {
return {};
}
const { senderId, replyToMessageId, isOutgoing } = chat.lastMessage;
const { senderId, replyToMessageId, isOutgoing } = chat.lastMessage || {};
const lastMessageSender = senderId ? selectUser(global, senderId) : undefined;
const lastMessageAction = getMessageAction(chat.lastMessage);
const lastMessageAction = chat.lastMessage ? getMessageAction(chat.lastMessage) : undefined;
const actionTargetMessage = lastMessageAction && replyToMessageId
? selectChatMessage(global, chat.id, replyToMessageId)
: undefined;
@ -423,7 +423,9 @@ export default memo(withGlobal<OwnProps>(
canScrollDown: isSelected && messageListType === 'thread',
canChangeFolder: (global.chatFolders.orderedIds?.length || 0) > 1,
lastSyncTime: global.lastSyncTime,
...(isOutgoing && { lastMessageOutgoingStatus: selectOutgoingStatus(global, chat.lastMessage) }),
...(isOutgoing && chat.lastMessage && {
lastMessageOutgoingStatus: selectOutgoingStatus(global, chat.lastMessage),
}),
...(privateChatUserId && {
user: selectUser(global, privateChatUserId),
userStatus: selectUserStatus(global, privateChatUserId),

View File

@ -429,7 +429,7 @@ function buildChatSummary(
return {
id,
type,
isListed: Boolean(lastMessage && !isRestricted && !isNotJoined && !migratedTo),
isListed: Boolean(!isRestricted && !isNotJoined && !migratedTo),
isArchived: folderId === ARCHIVED_FOLDER_ID,
isMuted: selectIsChatMuted(chat, notifySettings, notifyExceptions),
isUnread: Boolean(unreadCount || unreadMentionsCount || hasUnreadMark),