mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-26 19:14:02 +02:00
Added Up arrow shortcut to edit comments.
This commit is contained in:
parent
15254599e2
commit
3fadf2ee54
3 changed files with 23 additions and 6 deletions
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "data/data_replies_list.h"
|
#include "data/data_replies_list.h"
|
||||||
|
|
||||||
|
#include "base/unixtime.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "history/history_service.h"
|
#include "history/history_service.h"
|
||||||
|
@ -626,4 +627,20 @@ bool RepliesList::processMessagesIsEmpty(const MTPmessages_Messages &result) {
|
||||||
return (list.size() == skipped);
|
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
|
} // namespace Data
|
||||||
|
|
|
@ -31,6 +31,8 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<int> fullCount() const;
|
[[nodiscard]] rpl::producer<int> fullCount() const;
|
||||||
|
|
||||||
|
[[nodiscard]] HistoryItem *lastEditableMessage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Viewer;
|
struct Viewer;
|
||||||
|
|
||||||
|
|
|
@ -492,13 +492,11 @@ void RepliesWidget::setupComposeControls() {
|
||||||
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
|
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
|
||||||
if (e->key() == Qt::Key_Up) {
|
if (e->key() == Qt::Key_Up) {
|
||||||
if (!_composeControls->isEditingMessage()) {
|
if (!_composeControls->isEditingMessage()) {
|
||||||
// #TODO replies edit last sent message
|
if (const auto item = _replies->lastEditableMessage()) {
|
||||||
//auto &messages = session().data().scheduledMessages();
|
_inner->editMessageRequestNotify(item->fullId());
|
||||||
//if (const auto item = messages.lastEditableMessage(_history)) {
|
} else {
|
||||||
// _inner->editMessageRequestNotify(item->fullId());
|
|
||||||
//} else {
|
|
||||||
_scroll->keyPressEvent(e);
|
_scroll->keyPressEvent(e);
|
||||||
//}
|
}
|
||||||
} else {
|
} else {
|
||||||
_scroll->keyPressEvent(e);
|
_scroll->keyPressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue