Fixed restoring pinned community dialogs on launch.

This commit is contained in:
23rd
2026-08-03 08:31:16 +03:00
committed by John Preston
parent ce089ee16b
commit abc4e368e4
4 changed files with 47 additions and 5 deletions

View File

@@ -1269,6 +1269,12 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
} else if (!result->isLoaded()) {
result->setLoadedStatus(PeerData::LoadedStatus::Normal);
}
if (!_pinnedCommunitiesNotLoaded.empty()) {
if (const auto channel = result->asChannel()
; channel && channel->isCommunity()) {
checkPinnedCommunityLoaded(channel);
}
}
if (flags) {
session().changes().peerUpdated(result, flags);
}
@@ -2694,8 +2700,12 @@ void Session::applyDialog(
const auto channelId = ChannelId(data.vcommunity_id().v);
const auto channel = channelLoaded(channelId);
if (!channel || !channel->isCommunity()) {
if (data.is_pinned()) {
_pinnedCommunitiesNotLoaded.emplace(channelId);
}
return;
}
_pinnedCommunitiesNotLoaded.remove(channelId);
const auto history = this->history(channel);
notifySettings().apply(
peerFromChannel(channelId),
@@ -2704,6 +2714,13 @@ void Session::applyDialog(
setPinnedFromEntryList(history, data.is_pinned());
}
void Session::checkPinnedCommunityLoaded(not_null<ChannelData*> channel) {
if (!_pinnedCommunitiesNotLoaded.remove(peerToChannel(channel->id))) {
return;
}
session().api().reloadPinnedDialogs();
}
bool Session::pinnedCanPin(not_null<Dialogs::Entry*> entry) const {
if ([[maybe_unused]] const auto sublist = entry->asSublist()) {
if (sublist->parentChat()) {
@@ -2831,6 +2848,9 @@ const std::vector<Dialogs::Key> &Session::pinnedChatsOrder(
}
void Session::clearPinnedChats(Data::Folder *folder) {
if (!folder) {
_pinnedCommunitiesNotLoaded.clear();
}
chatsList(folder)->pinned()->clear();
}