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; return undefined;
} }
if (result instanceof GramJs.ChatInvite) { let chat: ApiChat | undefined;
await invokeRequest(new GramJs.messages.ImportChatInvite({ hash }), true);
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 { } 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( function preparePeers(

View File

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