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:
@@ -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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user