2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Implement pinned topics reordering.

This commit is contained in:
John Preston
2022-11-08 17:57:54 +04:00
parent c7741cb62a
commit 8a288476b8
17 changed files with 221 additions and 105 deletions

View File

@@ -315,7 +315,7 @@ private:
};
History *FindWastedPin(not_null<Data::Session*> data, Data::Folder *folder) {
const auto &order = data->pinnedChatsOrder(folder, FilterId());
const auto &order = data->pinnedChatsOrder(folder);
for (const auto &pinned : order) {
if (const auto history = pinned.history()) {
if (history->peer->isChat()
@@ -336,24 +336,22 @@ void AddChatMembers(
bool PinnedLimitReached(
not_null<Window::SessionController*> controller,
not_null<History*> history,
FilterId filterId) {
Expects(filterId != 0 || history->folderKnown());
const auto owner = &history->owner();
const auto folder = history->folder();
if (owner->pinnedCanPin(folder, filterId, history)) {
not_null<Data::Thread*> thread) {
const auto owner = &thread->owner();
if (owner->pinnedCanPin(thread)) {
return false;
}
// Some old chat, that was converted, maybe is still pinned.
const auto wasted = filterId ? nullptr : FindWastedPin(owner, folder);
const auto history = thread->asHistory();
if (!history) {
return true;
}
const auto folder = history->folder();
const auto wasted = FindWastedPin(owner, folder);
if (wasted) {
owner->setChatPinned(wasted, FilterId(), false);
owner->setChatPinned(history, FilterId(), true);
history->session().api().savePinnedOrder(folder);
} else if (filterId) {
controller->show(
Box(FilterPinsLimitBox, &history->session(), filterId));
} else if (folder) {
controller->show(Box(FolderPinsLimitBox, &history->session()));
} else {
@@ -362,6 +360,19 @@ bool PinnedLimitReached(
return true;
}
bool PinnedLimitReached(
not_null<Window::SessionController*> controller,
not_null<History*> history,
FilterId filterId) {
const auto owner = &history->owner();
if (owner->pinnedCanPin(filterId, history)) {
return false;
}
controller->show(
Box(FilterPinsLimitBox, &history->session(), filterId));
return true;
}
void TogglePinnedThread(
not_null<Window::SessionController*> controller,
not_null<Data::Thread*> thread) {