mirror of
https://github.com/danog/telegram-tt.git
synced 2025-01-21 21:01:29 +01:00
New Chat: Fix freezing when users disable adding them to groups (#1552)
This commit is contained in:
parent
5d3ceb9e64
commit
7ea9dd116f
@ -567,7 +567,7 @@ export async function createGroupChat({
|
||||
const result = await invokeRequest(new GramJs.messages.CreateChat({
|
||||
title,
|
||||
users: users.map(({ id, accessHash }) => buildInputEntity(id, accessHash)) as GramJs.InputUser[],
|
||||
}), true);
|
||||
}), true, true);
|
||||
|
||||
// `createChat` can return a lot of different update types according to docs,
|
||||
// but currently chat creation returns only `Updates` type.
|
||||
|
@ -113,7 +113,7 @@ const NewChatStep2: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
}
|
||||
}, [creationProgress, onReset]);
|
||||
|
||||
const renderedError = creationError || (
|
||||
const renderedError = (creationError && lang(creationError)) || (
|
||||
error !== chatTitleEmptyError && error !== channelTitleEmptyError
|
||||
? error
|
||||
: undefined
|
||||
|
@ -1088,27 +1088,52 @@ async function createGroupChat(title: string, users: ApiUser[], photo?: File) {
|
||||
},
|
||||
});
|
||||
|
||||
const createdChat = await callApi('createGroupChat', { title, users });
|
||||
if (!createdChat) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const createdChat = await callApi('createGroupChat', {
|
||||
title,
|
||||
users,
|
||||
});
|
||||
|
||||
const { id: chatId } = createdChat;
|
||||
if (!createdChat) {
|
||||
return;
|
||||
}
|
||||
|
||||
let global = getGlobal();
|
||||
global = updateChat(global, chatId, createdChat);
|
||||
global = {
|
||||
...global,
|
||||
chatCreation: {
|
||||
...global.chatCreation,
|
||||
progress: createdChat ? ChatCreationProgress.Complete : ChatCreationProgress.Error,
|
||||
},
|
||||
};
|
||||
setGlobal(global);
|
||||
getDispatch().openChat({ id: chatId, shouldReplaceHistory: true });
|
||||
const { id: chatId } = createdChat;
|
||||
|
||||
if (chatId && photo) {
|
||||
await callApi('editChatPhoto', { chatId, photo });
|
||||
let global = getGlobal();
|
||||
global = updateChat(global, chatId, createdChat);
|
||||
global = {
|
||||
...global,
|
||||
chatCreation: {
|
||||
...global.chatCreation,
|
||||
progress: createdChat ? ChatCreationProgress.Complete : ChatCreationProgress.Error,
|
||||
},
|
||||
};
|
||||
setGlobal(global);
|
||||
getDispatch()
|
||||
.openChat({
|
||||
id: chatId,
|
||||
shouldReplaceHistory: true,
|
||||
});
|
||||
|
||||
if (chatId && photo) {
|
||||
await callApi('editChatPhoto', {
|
||||
chatId,
|
||||
photo,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
if (e.message === 'USERS_TOO_FEW') {
|
||||
const global = getGlobal();
|
||||
setGlobal({
|
||||
...global,
|
||||
chatCreation: {
|
||||
...global.chatCreation,
|
||||
progress: ChatCreationProgress.Error,
|
||||
error: 'CreateGroupError',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user