Chat List: Fix deleting service chat with Telegram (#2043)

This commit is contained in:
Alexander Zinchuk 2022-09-20 14:59:16 +02:00
parent 2d2cc73589
commit 04cffadd06
3 changed files with 7 additions and 4 deletions

View File

@ -822,7 +822,7 @@ async function loadViewportMessages(
let global = getGlobal();
const localMessages = chatId === SERVICE_NOTIFICATIONS_USER_ID
? global.serviceNotifications.map(({ message }) => message)
? global.serviceNotifications.filter((notification) => !notification.isHidden).map(({ message }) => message)
: [];
const allMessages = ([] as ApiMessage[]).concat(messages, localMessages);
const byId = buildCollectionByKey(allMessages, 'id');

View File

@ -106,7 +106,7 @@ async function loadAndReplaceMessages() {
if (result && newCurrentChatId === currentChatId) {
const currentMessageListInfo = global.messages.byChatId[currentChatId];
const localMessages = currentChatId === SERVICE_NOTIFICATIONS_USER_ID
? global.serviceNotifications.map(({ message }) => message)
? global.serviceNotifications.filter((notification) => !notification.isHidden).map(({ message }) => message)
: [];
const allMessages = ([] as ApiMessage[]).concat(result.messages, localMessages);
const byId = buildCollectionByKey(allMessages, 'id');

View File

@ -5,7 +5,9 @@ import type { GlobalState } from '../global/types';
import type { NotifyException, NotifySettings } from '../types';
import type { ApiChat, ApiChatFolder, ApiUser } from '../api/types';
import { ALL_FOLDER_ID, ARCHIVED_FOLDER_ID, DEBUG } from '../config';
import {
ALL_FOLDER_ID, ARCHIVED_FOLDER_ID, DEBUG, SERVICE_NOTIFICATIONS_USER_ID,
} from '../config';
import { selectNotifySettings, selectNotifyExceptions } from '../global/selectors';
import { selectIsChatMuted } from '../global/helpers';
import { onIdle, throttle } from './schedulers';
@ -425,11 +427,12 @@ function buildChatSummary(
} = chat;
const userInfo = type === 'chatTypePrivate' && user;
const shouldHideServiceChat = chat.id === SERVICE_NOTIFICATIONS_USER_ID && !chat.lastMessage;
return {
id,
type,
isListed: Boolean(!isRestricted && !isNotJoined && !migratedTo),
isListed: Boolean(!isRestricted && !isNotJoined && !migratedTo && !shouldHideServiceChat),
isArchived: folderId === ARCHIVED_FOLDER_ID,
isMuted: selectIsChatMuted(chat, notifySettings, notifyExceptions),
isUnread: Boolean(unreadCount || unreadMentionsCount || hasUnreadMark),