mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-01 07:05:13 +00:00
Alpha 1.0.10: unpinning converted chat on demand.
If we want to pin a chat and we have reached the limit we now check for a deactivated (converted to supergroup) chat that is pinned and is not in the chats list and just silently unpin it if it is found. Also possible UB fix for a waveform encoding and decoding.
This commit is contained in:
@@ -1976,7 +1976,25 @@ void MainWidget::fillPeerMenu(PeerData *peer, base::lambda<QAction*(const QStrin
|
||||
auto history = App::history(peer);
|
||||
auto isPinned = !history->isPinnedDialog();
|
||||
if (isPinned && App::histories().pinnedCount() >= Global::PinnedDialogsCountMax()) {
|
||||
Ui::show(Box<InformBox>(lng_error_pinned_max(lt_count, Global::PinnedDialogsCountMax())));
|
||||
// Some old chat, that was converted to supergroup, maybe is still pinned.
|
||||
auto findWastedPin = []() -> History* {
|
||||
auto order = App::histories().getPinnedOrder();
|
||||
for_const (auto pinned, order) {
|
||||
if (pinned->peer->isChat()
|
||||
&& pinned->peer->asChat()->isDeactivated()
|
||||
&& !pinned->inChatList(Dialogs::Mode::All)) {
|
||||
return pinned;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
if (auto wasted = findWastedPin()) {
|
||||
wasted->setPinnedDialog(false);
|
||||
history->setPinnedDialog(isPinned);
|
||||
App::histories().savePinnedToServer();
|
||||
} else {
|
||||
Ui::show(Box<InformBox>(lng_error_pinned_max(lt_count, Global::PinnedDialogsCountMax())));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user