Forum: Fix wrong channel opening when enabled (#3849)
This commit is contained in:
parent
e26250071d
commit
a132f88878
@ -1221,7 +1221,14 @@ export async function migrateChat(chat: ApiChat) {
|
|||||||
|
|
||||||
updateLocalDb(result);
|
updateLocalDb(result);
|
||||||
|
|
||||||
return buildApiChatFromPreview(result.chats[1]);
|
const newChannelId = result.updates
|
||||||
|
.find((update): update is GramJs.UpdateChannel => update instanceof GramJs.UpdateChannel)!.channelId;
|
||||||
|
|
||||||
|
const newChannel = result.chats.find((c) => (
|
||||||
|
c instanceof GramJs.Channel && c.id.toString() === newChannelId.toString()
|
||||||
|
))!;
|
||||||
|
|
||||||
|
return buildApiChatFromPreview(newChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function openChatByInvite(hash: string) {
|
export async function openChatByInvite(hash: string) {
|
||||||
|
|||||||
@ -1257,7 +1257,7 @@ addActionHandler('updateChatMemberBannedRights', async (global, actions, payload
|
|||||||
|
|
||||||
global = getGlobal();
|
global = getGlobal();
|
||||||
|
|
||||||
const updatedFullInfo = selectChatFullInfo(global, chatId);
|
const updatedFullInfo = selectChatFullInfo(global, chat.id);
|
||||||
if (!updatedFullInfo) {
|
if (!updatedFullInfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1267,7 +1267,7 @@ addActionHandler('updateChatMemberBannedRights', async (global, actions, payload
|
|||||||
const isBanned = Boolean(bannedRights.viewMessages);
|
const isBanned = Boolean(bannedRights.viewMessages);
|
||||||
const isUnblocked = !Object.keys(bannedRights).length;
|
const isUnblocked = !Object.keys(bannedRights).length;
|
||||||
|
|
||||||
global = updateChatFullInfo(global, chatId, {
|
global = updateChatFullInfo(global, chat.id, {
|
||||||
...(members && isBanned && {
|
...(members && isBanned && {
|
||||||
members: members.filter((m) => m.userId !== userId),
|
members: members.filter((m) => m.userId !== userId),
|
||||||
}),
|
}),
|
||||||
@ -1330,7 +1330,7 @@ addActionHandler('updateChatAdmin', async (global, actions, payload): Promise<vo
|
|||||||
|
|
||||||
if (newAdminMembersById) {
|
if (newAdminMembersById) {
|
||||||
global = getGlobal();
|
global = getGlobal();
|
||||||
global = updateChatFullInfo(global, chatId, { adminMembersById: newAdminMembersById });
|
global = updateChatFullInfo(global, chat.id, { adminMembersById: newAdminMembersById });
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1806,12 +1806,6 @@ addActionHandler('toggleForum', async (global, actions, payload): Promise<void>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
global = getGlobal();
|
|
||||||
|
|
||||||
const prevIsForum = chat.isForum;
|
|
||||||
global = updateChat(global, chatId, { isForum: isEnabled });
|
|
||||||
setGlobal(global);
|
|
||||||
|
|
||||||
let result: true | undefined;
|
let result: true | undefined;
|
||||||
try {
|
try {
|
||||||
result = await callApi('toggleForum', { chat, isEnabled });
|
result = await callApi('toggleForum', { chat, isEnabled });
|
||||||
@ -1823,10 +1817,16 @@ addActionHandler('toggleForum', async (global, actions, payload): Promise<void>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result) {
|
if (result) {
|
||||||
global = getGlobal();
|
global = getGlobal();
|
||||||
global = updateChat(global, chatId, { isForum: prevIsForum });
|
global = updateChat(global, chat.id, { isForum: isEnabled });
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
|
|
||||||
|
if (!isEnabled) {
|
||||||
|
actions.closeForumPanel({ tabId });
|
||||||
|
} else {
|
||||||
|
actions.openForumPanel({ chatId: chat.id, tabId });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -74,7 +74,7 @@ addActionHandler('updatePublicLink', async (global, actions, payload): Promise<v
|
|||||||
|
|
||||||
global = getGlobal();
|
global = getGlobal();
|
||||||
global = updateManagementProgress(global, result ? ManagementProgress.Complete : ManagementProgress.Error, tabId);
|
global = updateManagementProgress(global, result ? ManagementProgress.Complete : ManagementProgress.Error, tabId);
|
||||||
global = updateManagement(global, chatId, {
|
global = updateManagement(global, chat.id, {
|
||||||
isUsernameAvailable: undefined,
|
isUsernameAvailable: undefined,
|
||||||
checkedUsername: undefined,
|
checkedUsername: undefined,
|
||||||
error: undefined,
|
error: undefined,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user