Message List: Fix opening some private channels

This commit is contained in:
Alexander Zinchuk 2021-06-29 15:48:24 +03:00
parent 297352d329
commit 93991e5cb1
2 changed files with 26 additions and 8 deletions

View File

@ -904,13 +904,32 @@ export async function openChatByInvite(hash: string) {
return undefined;
}
if (result instanceof GramJs.ChatInvite) {
await invokeRequest(new GramJs.messages.ImportChatInvite({ hash }), true);
let chat: ApiChat | undefined;
return undefined;
if (result instanceof GramJs.ChatInvite) {
const updates = await invokeRequest(new GramJs.messages.ImportChatInvite({ hash }), true);
if (!(updates instanceof GramJs.Updates) || !updates.chats.length) {
return undefined;
}
chat = buildApiChatFromPreview(updates.chats[0]);
} else {
return buildApiChatFromPreview(result.chat);
chat = buildApiChatFromPreview(result.chat);
if (chat) {
onUpdate({
'@type': 'updateChat',
id: chat.id,
chat,
});
}
}
if (!chat) {
return undefined;
}
return { chatId: chat.id };
}
function preparePeers(

View File

@ -386,13 +386,12 @@ addReducer('openTelegramLink', (global, actions, payload) => {
const hash = match[1];
(async () => {
const chat = await callApi('openChatByInvite', hash);
if (!chat) {
const result = await callApi('openChatByInvite', hash);
if (!result) {
return;
}
actions.openChat({ id: chat.id });
actions.openChat({ id: result.chatId });
})();
} else {
match = RE_TME_LINK.exec(url)!;