2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

Handle migration to supergroups in boxes.

This commit is contained in:
John Preston
2019-01-14 10:34:51 +04:00
parent 3c44bdb6b7
commit 9728ddeaf9
29 changed files with 426 additions and 231 deletions

View File

@@ -520,7 +520,7 @@ const ChannelData *PeerData::asChannelOrMigrated() const {
ChatData *PeerData::migrateFrom() const {
if (const auto megagroup = asMegagroup()) {
return megagroup->amIn()
? megagroup->mgInfo->migrateFromPtr
? megagroup->getMigrateFromChat()
: nullptr;
}
return nullptr;
@@ -528,13 +528,27 @@ ChatData *PeerData::migrateFrom() const {
ChannelData *PeerData::migrateTo() const {
if (const auto chat = asChat()) {
if (const auto migrateTo = chat->migrateToPtr) {
return migrateTo->amIn() ? migrateTo : nullptr;
if (const auto result = chat->getMigrateToChannel()) {
return result->amIn() ? result : nullptr;
}
}
return nullptr;
}
not_null<PeerData*> PeerData::migrateToOrMe() {
if (const auto channel = migrateTo()) {
return channel;
}
return this;
}
not_null<const PeerData*> PeerData::migrateToOrMe() const {
if (const auto channel = migrateTo()) {
return channel;
}
return this;
}
Data::Feed *PeerData::feed() const {
if (const auto channel = asChannel()) {
return channel->feed();