2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +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

@@ -139,8 +139,9 @@ DialogsInner::DialogsInner(QWidget *parent, not_null<Window::Controller*> contro
| UpdateFlag::NameChanged
| UpdateFlag::PhotoChanged
| UpdateFlag::UserIsContact
| UpdateFlag::UserOccupiedChanged;
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(changes, [this](const Notify::PeerUpdate &update) {
| UpdateFlag::UserOccupiedChanged
| UpdateFlag::MigrationChanged;
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(changes, [=](const Notify::PeerUpdate &update) {
if (update.flags & UpdateFlag::ChatPinnedChanged) {
stopReorderPinned();
}
@@ -156,6 +157,11 @@ DialogsInner::DialogsInner(QWidget *parent, not_null<Window::Controller*> contro
userIsContactUpdated(user);
}
}
if (update.flags & UpdateFlag::MigrationChanged) {
if (const auto chat = update.peer->asChat()) {
handleChatMigration(chat);
}
}
}));
Auth().data().feedUpdated(
) | rpl::start_with_next([=](const Data::FeedUpdate &update) {
@@ -175,6 +181,22 @@ DialogsInner::DialogsInner(QWidget *parent, not_null<Window::Controller*> contro
setupShortcuts();
}
void DialogsInner::handleChatMigration(not_null<ChatData*> chat) {
const auto channel = chat->migrateTo();
if (!channel) {
return;
}
if (const auto from = chat->owner().historyLoaded(chat)) {
if (const auto to = chat->owner().historyLoaded(channel)) {
if (to->inChatList(Dialogs::Mode::All)
&& from->inChatList(Dialogs::Mode::All)) {
removeDialog(from);
}
}
}
}
int DialogsInner::dialogsOffset() const {
return _dialogsImportant ? st::dialogsImportantBarHeight : 0;
}