2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Fix leaving channels and supergroups.

Fixes #5838.
This commit is contained in:
John Preston
2019-03-25 15:49:57 +04:00
parent d7a67a6a1c
commit bb2e683dea
3 changed files with 23 additions and 16 deletions

View File

@@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "observer_peer.h"
#include "auth_session.h"
#include "apiwrap.h"
#include "mainwidget.h"
#include "core/application.h"
#include "core/crash_reports.h" // for CrashReports::SetAnnotation
#include "ui/image/image.h"
@@ -717,6 +718,25 @@ History *Session::historyLoaded(const PeerData *peer) {
return peer ? historyLoaded(peer->id) : nullptr;
}
void Session::deleteConversationLocally(not_null<PeerData*> peer) {
const auto history = historyLoaded(peer);
if (history) {
setPinnedDialog(history, false);
App::main()->removeDialog(history);
history->clear();
}
if (const auto channel = peer->asMegagroup()) {
channel->addFlags(MTPDchannel::Flag::f_left);
if (const auto from = channel->getMigrateFromChat()) {
if (const auto migrated = historyLoaded(from)) {
migrated->updateChatListExistence();
}
}
} else if (history) {
history->markFullyLoaded();
}
}
void Session::registerSendAction(
not_null<History*> history,
not_null<UserData*> user,

View File

@@ -125,6 +125,8 @@ public:
[[nodiscard]] not_null<History*> history(not_null<const PeerData*> peer);
[[nodiscard]] History *historyLoaded(const PeerData *peer);
void deleteConversationLocally(not_null<PeerData*> peer);
void registerSendAction(
not_null<History*> history,
not_null<UserData*> user,