Fixes for t.me links (#1495)

This commit is contained in:
Alexander Zinchuk 2021-10-13 14:38:50 +03:00
parent 90a695a0cd
commit 2243343ccc

View File

@ -38,7 +38,7 @@ import {
selectChatByUsername, selectChatByUsername,
selectThreadTopMessageId, selectThreadTopMessageId,
selectCurrentMessageList, selectCurrentMessageList,
selectThreadInfo, selectThreadInfo, selectCurrentChat,
} from '../../selectors'; } from '../../selectors';
import { buildCollectionByKey } from '../../../util/iteratees'; import { buildCollectionByKey } from '../../../util/iteratees';
import { debounce, pause, throttle } from '../../../util/schedulers'; import { debounce, pause, throttle } from '../../../util/schedulers';
@ -562,7 +562,7 @@ addReducer('openTelegramLink', (global, actions, payload) => {
} else { } else {
actions.openChatByUsername({ actions.openChatByUsername({
username, username,
messageId, messageId: messageId || chatOrChannelPostId,
commentId, commentId,
}); });
} }
@ -586,11 +586,32 @@ addReducer('openChatByUsername', (global, actions, payload) => {
const { username, messageId, commentId } = payload!; const { username, messageId, commentId } = payload!;
(async () => { (async () => {
const chat = selectCurrentChat(global);
if (!commentId) { if (!commentId) {
if (chat && chat.username === username) {
actions.focusMessage({ chatId: chat.id, messageId });
return;
}
await openChatByUsername(actions, username, messageId); await openChatByUsername(actions, username, messageId);
return; return;
} }
const { chatId, type } = selectCurrentMessageList(global) || {};
const usernameChat = selectChatByUsername(global, username);
if (chatId && usernameChat && type === 'thread') {
const threadInfo = selectThreadInfo(global, chatId, messageId);
if (threadInfo && threadInfo.chatId === chatId) {
actions.focusMessage({
chatId: threadInfo.chatId,
threadId: threadInfo.threadId,
messageId: commentId,
});
return;
}
}
if (!messageId) return; if (!messageId) return;
await openCommentsByUsername(actions, username, messageId, commentId); await openCommentsByUsername(actions, username, messageId, commentId);