2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-02 23:45:44 +00:00

Refactored handle of last editable message on Up arrow in sections.

This commit is contained in:
23rd
2021-01-31 07:22:46 +03:00
committed by John Preston
parent b13e5ddce9
commit 062c451c27
10 changed files with 41 additions and 83 deletions

View File

@@ -546,26 +546,4 @@ int32 ScheduledMessages::countListHash(const List &list) const {
return HashFinalize(hash);
}
HistoryItem *ScheduledMessages::lastEditableMessage(
not_null<History*> history) {
const auto i = _data.find(history);
if (i == end(_data)) {
return nullptr;
}
auto &list = i->second;
sort(list);
const auto items = ranges::view::reverse(list.items);
const auto now = base::unixtime::now();
auto proj = [&](const OwnedItem &item) {
return item->allowsEdit(now);
};
const auto it = ranges::find_if(items, std::move(proj));
return (it == end(items))
? nullptr
: history->owner().groups().findItemToEdit((*it).get()).get();
}
} // namespace Data