From 38a1d7ac8e2071f5252e1b50d0d8ab2ffd09a5e7 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 14 May 2024 23:31:34 +0300 Subject: [PATCH] Always create chat to update its order when channel status changes. --- td/telegram/ChatManager.cpp | 17 +++++++---------- td/telegram/ChatManager.h | 1 - 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/td/telegram/ChatManager.cpp b/td/telegram/ChatManager.cpp index 45f144df3..c61a656d9 100644 --- a/td/telegram/ChatManager.cpp +++ b/td/telegram/ChatManager.cpp @@ -5004,17 +5004,11 @@ void ChatManager::update_channel(Channel *c, ChannelId channel_id, bool from_bin } bool have_read_access = have_input_peer_channel(c, channel_id, AccessRights::Read); - bool is_member = c->status.is_member(); if (c->had_read_access && !have_read_access) { send_closure_later(G()->messages_manager(), &MessagesManager::on_dialog_deleted, DialogId(channel_id), Promise()); - } else if (!from_database && c->was_member != is_member) { - DialogId dialog_id(channel_id); - send_closure_later(G()->messages_manager(), &MessagesManager::force_create_dialog, dialog_id, "update channel", - true, true); } c->had_read_access = have_read_access; - c->was_member = is_member; if (c->cache_version != Channel::CACHE_VERSION && !c->is_repaired && have_input_peer_channel(c, channel_id, AccessRights::Read) && !G()->close_flag()) { @@ -6976,13 +6970,16 @@ void ChatManager::on_channel_status_changed(Channel *c, ChannelId channel_id, co Promise()); } if (!is_bot && old_status.is_member() != new_status.is_member()) { + DialogId dialog_id(channel_id); if (new_status.is_member()) { - send_closure_later(td_->story_manager_actor_, &StoryManager::reload_dialog_expiring_stories, - DialogId(channel_id)); + send_closure_later(td_->story_manager_actor_, &StoryManager::reload_dialog_expiring_stories, dialog_id); } else { - send_closure_later(td_->story_manager_actor_, &StoryManager::on_dialog_active_stories_order_updated, - DialogId(channel_id), "on_channel_status_changed"); + send_closure_later(td_->story_manager_actor_, &StoryManager::on_dialog_active_stories_order_updated, dialog_id, + "on_channel_status_changed"); } + + send_closure_later(G()->messages_manager(), &MessagesManager::force_create_dialog, dialog_id, + "on_channel_status_changed", true, true); } // must not load ChannelFull, because must not change the Channel diff --git a/td/telegram/ChatManager.h b/td/telegram/ChatManager.h index 616fbe6ba..095967580 100644 --- a/td/telegram/ChatManager.h +++ b/td/telegram/ChatManager.h @@ -517,7 +517,6 @@ class ChatManager final : public Actor { bool is_noforwards_changed = true; bool is_creator_changed = true; bool had_read_access = true; - bool was_member = false; bool is_being_updated = false; bool is_changed = true; // have new changes that need to be sent to the client and database bool need_save_to_database = true; // have new changes that need only to be saved to the database