Changed Up arrow shortcut for albums to edit item with caption.

Fixed #10134.
This commit is contained in:
23rd 2021-01-18 18:04:03 +03:00 committed by John Preston
parent ad761011d6
commit eb42a77eb7
5 changed files with 26 additions and 3 deletions

View File

@ -145,4 +145,20 @@ void Groups::refreshViews(const HistoryItemsList &items) {
}
}
not_null<HistoryItem*> Groups::findItemToEdit(
not_null<HistoryItem*> item) const {
const auto group = find(item);
if (!group) {
return item;
}
const auto &list = group->items;
const auto it = ranges::find_if(
list,
ranges::not_fn(&HistoryItem::emptyText));
if (it == end(list)) {
return list.front();
}
return (*it);
}
} // namespace Data

View File

@ -31,6 +31,8 @@ public:
const Group *find(not_null<HistoryItem*> item) const;
not_null<HistoryItem*> findItemToEdit(not_null<HistoryItem*> item) const;
private:
HistoryItemsList::const_iterator findPositionForItem(
const HistoryItemsList &group,

View File

@ -640,7 +640,9 @@ HistoryItem *RepliesList::lastEditableMessage() {
return false;
};
const auto it = ranges::find_if(_list, std::move(proj));
return (it == end(_list)) ? nullptr : message(*it);
return (it == end(_list))
? nullptr
: _history->owner().groups().findItemToEdit(message(*it));
}
} // namespace Data

View File

@ -558,8 +558,11 @@ HistoryItem *ScheduledMessages::lastEditableMessage(
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();
return (it == end(items))
? nullptr
: history->owner().groups().findItemToEdit((*it).get());
}
} // namespace Data

View File

@ -2713,7 +2713,7 @@ HistoryItem *History::lastEditableMessage() const {
for (const auto &message : ranges::view::reverse(block->messages)) {
const auto item = message->data();
if (item->allowsEdit(now)) {
return item;
return owner().groups().findItemToEdit(item);
}
}
}