1
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-03-11 08:48:14 +00:00

Added Up arrow shortcut to edit comments.

This commit is contained in:
23rd 2021-01-11 00:33:56 +03:00
parent 15254599e2
commit 3fadf2ee54
3 changed files with 23 additions and 6 deletions

View File

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "data/data_replies_list.h"
#include "base/unixtime.h"
#include "history/history.h"
#include "history/history_item.h"
#include "history/history_service.h"
@ -626,4 +627,20 @@ bool RepliesList::processMessagesIsEmpty(const MTPmessages_Messages &result) {
return (list.size() == skipped);
}
HistoryItem *RepliesList::lastEditableMessage() {
const auto message = [&](MsgId msgId) {
return _history->owner().message(_history->channelId(), msgId);
};
const auto now = base::unixtime::now();
auto proj = [&](MsgId msgId) {
if (const auto item = message(msgId)) {
return item->allowsEdit(now);
}
return false;
};
const auto it = ranges::find_if(_list, std::move(proj));
return (it == end(_list)) ? nullptr : message(*it);
}
} // namespace Data

View File

@ -31,6 +31,8 @@ public:
[[nodiscard]] rpl::producer<int> fullCount() const;
[[nodiscard]] HistoryItem *lastEditableMessage();
private:
struct Viewer;

View File

@ -492,13 +492,11 @@ void RepliesWidget::setupComposeControls() {
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
if (e->key() == Qt::Key_Up) {
if (!_composeControls->isEditingMessage()) {
// #TODO replies edit last sent message
//auto &messages = session().data().scheduledMessages();
//if (const auto item = messages.lastEditableMessage(_history)) {
// _inner->editMessageRequestNotify(item->fullId());
//} else {
if (const auto item = _replies->lastEditableMessage()) {
_inner->editMessageRequestNotify(item->fullId());
} else {
_scroll->keyPressEvent(e);
//}
}
} else {
_scroll->keyPressEvent(e);
}