Connection: Fix reconnect logic being called on sync (#3840)

This commit is contained in:
Alexander Zinchuk 2023-09-13 12:21:43 +02:00
parent fb614840f6
commit aa2c065eef

View File

@ -221,17 +221,19 @@ function onUpdateConnectionState<T extends GlobalState>(
}; };
setGlobal(global); setGlobal(global);
const channelStackIds = Object.values(global.byTabId) if (global.isSynced) {
.flatMap((tab) => tab.messageLists) const channelStackIds = Object.values(global.byTabId)
.map((messageList) => messageList.chatId) .flatMap((tab) => tab.messageLists)
.filter((chatId) => { .map((messageList) => messageList.chatId)
const chat = global.chats.byId[chatId]; .filter((chatId) => {
return chat && (isChatChannel(chat) || isChatSuperGroup(chat)); const chat = global.chats.byId[chatId];
}); return chat && (isChatChannel(chat) || isChatSuperGroup(chat));
if (connectionState === 'connectionStateReady' && channelStackIds.length) { });
unique(channelStackIds).forEach((chatId) => { if (connectionState === 'connectionStateReady' && channelStackIds.length) {
actions.requestChannelDifference({ chatId }); unique(channelStackIds).forEach((chatId) => {
}); actions.requestChannelDifference({ chatId });
});
}
} }
if (connectionState === 'connectionStateBroken') { if (connectionState === 'connectionStateBroken') {