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

Unified checking for editable message.

This commit is contained in:
23rd
2021-01-11 00:10:29 +03:00
parent 1607752cf9
commit 15254599e2
9 changed files with 19 additions and 36 deletions

View File

@@ -543,7 +543,8 @@ int32 ScheduledMessages::countListHash(const List &list) const {
return HashFinalize(hash);
}
HistoryItem *ScheduledMessages::lastSentMessage(not_null<History*> history) {
HistoryItem *ScheduledMessages::lastEditableMessage(
not_null<History*> history) {
const auto i = _data.find(history);
if (i == end(_data)) {
return nullptr;
@@ -552,9 +553,12 @@ HistoryItem *ScheduledMessages::lastSentMessage(not_null<History*> history) {
sort(list);
const auto items = ranges::view::reverse(list.items);
const auto it = ranges::find_if(
items,
&HistoryItem::canBeEditedFromHistory);
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 : (*it).get();
}