Avoid using contacts.ResolvePhone for service notifications chat (#1999)
This commit is contained in:
parent
838e07c8ae
commit
d9bee45147
@ -200,7 +200,6 @@ export const COUNTRIES_WITH_12H_TIME_FORMAT = new Set(['AU', 'BD', 'CA', 'CO', '
|
|||||||
|
|
||||||
// MTProto constants
|
// MTProto constants
|
||||||
export const SERVICE_NOTIFICATIONS_USER_ID = '777000';
|
export const SERVICE_NOTIFICATIONS_USER_ID = '777000';
|
||||||
export const SERVICE_NOTIFICATIONS_NUMBER = '42777';
|
|
||||||
export const REPLIES_USER_ID = '1271266957'; // TODO For Test connection ID must be equal to 708513
|
export const REPLIES_USER_ID = '1271266957'; // TODO For Test connection ID must be equal to 708513
|
||||||
export const ALL_FOLDER_ID = 0;
|
export const ALL_FOLDER_ID = 0;
|
||||||
export const ARCHIVED_FOLDER_ID = 1;
|
export const ARCHIVED_FOLDER_ID = 1;
|
||||||
|
|||||||
@ -15,7 +15,9 @@ import {
|
|||||||
CHAT_LIST_LOAD_SLICE,
|
CHAT_LIST_LOAD_SLICE,
|
||||||
RE_TG_LINK,
|
RE_TG_LINK,
|
||||||
SERVICE_NOTIFICATIONS_USER_ID,
|
SERVICE_NOTIFICATIONS_USER_ID,
|
||||||
TMP_CHAT_ID, ALL_FOLDER_ID, DEBUG, SERVICE_NOTIFICATIONS_NUMBER,
|
TMP_CHAT_ID,
|
||||||
|
ALL_FOLDER_ID,
|
||||||
|
DEBUG,
|
||||||
} from '../../../config';
|
} from '../../../config';
|
||||||
import { callApi } from '../../../api/gramjs';
|
import { callApi } from '../../../api/gramjs';
|
||||||
import {
|
import {
|
||||||
@ -45,6 +47,15 @@ import { selectCurrentLimit } from '../../selectors/limits';
|
|||||||
const TOP_CHAT_MESSAGES_PRELOAD_INTERVAL = 100;
|
const TOP_CHAT_MESSAGES_PRELOAD_INTERVAL = 100;
|
||||||
const INFINITE_LOOP_MARKER = 100;
|
const INFINITE_LOOP_MARKER = 100;
|
||||||
|
|
||||||
|
const SERVICE_NOTIFICATIONS_USER_MOCK: ApiUser = {
|
||||||
|
id: SERVICE_NOTIFICATIONS_USER_ID,
|
||||||
|
accessHash: '0',
|
||||||
|
type: 'userTypeRegular',
|
||||||
|
isMin: true,
|
||||||
|
username: '',
|
||||||
|
phoneNumber: '',
|
||||||
|
};
|
||||||
|
|
||||||
const runThrottledForLoadTopChats = throttle((cb) => cb(), 3000, true);
|
const runThrottledForLoadTopChats = throttle((cb) => cb(), 3000, true);
|
||||||
const runDebouncedForLoadFullChat = debounce((cb) => cb(), 500, false, true);
|
const runDebouncedForLoadFullChat = debounce((cb) => cb(), 500, false, true);
|
||||||
|
|
||||||
@ -1111,16 +1122,23 @@ async function loadChats(
|
|||||||
if (shouldReplace && listType === 'active') {
|
if (shouldReplace && listType === 'active') {
|
||||||
// Always include service notifications chat
|
// Always include service notifications chat
|
||||||
if (!chatIds.includes(SERVICE_NOTIFICATIONS_USER_ID)) {
|
if (!chatIds.includes(SERVICE_NOTIFICATIONS_USER_ID)) {
|
||||||
const chat = await callApi('getChatByPhoneNumber', SERVICE_NOTIFICATIONS_NUMBER);
|
const result2 = await callApi('fetchChat', {
|
||||||
|
type: 'user',
|
||||||
|
user: SERVICE_NOTIFICATIONS_USER_MOCK,
|
||||||
|
});
|
||||||
|
|
||||||
global = getGlobal();
|
global = getGlobal();
|
||||||
if (chat) {
|
|
||||||
chatIds.unshift(chat.id);
|
const notificationsChat = result2 && selectChat(global, result2.chatId);
|
||||||
result.chats.unshift(chat);
|
if (notificationsChat) {
|
||||||
|
chatIds.unshift(notificationsChat.id);
|
||||||
|
result.chats.unshift(notificationsChat);
|
||||||
if (lastLocalServiceMessage) {
|
if (lastLocalServiceMessage) {
|
||||||
chat.lastMessage = lastLocalServiceMessage;
|
notificationsChat.lastMessage = lastLocalServiceMessage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentChat = selectCurrentChat(global);
|
const currentChat = selectCurrentChat(global);
|
||||||
const visibleChats = currentChat ? [currentChat] : [];
|
const visibleChats = currentChat ? [currentChat] : [];
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user