This commit is contained in:
test 2021-07-20 22:10:04 +03:00 committed by John Preston
parent 840bb447ba
commit f189ffc6ac
3 changed files with 28 additions and 0 deletions

View file

@ -1641,6 +1641,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_context_mark_read_sure" = "Are you sure you want to mark all chats from this folder as read?";
"lng_context_mark_read_all" = "Mark all chats as read";
"lng_context_mark_read_all_sure" = "Are you sure you want to mark all chats as read?";
"lng_context_mark_read_mentions_all" = "Mark all mentions as read"
"lng_context_archive_expand" = "Expand";
"lng_context_archive_collapse" = "Collapse";
"lng_context_archive_to_menu" = "Move to main menu";

View file

@ -6964,6 +6964,31 @@ void HistoryWidget::synteticScrollToY(int y) {
_synteticScrollEvent = false;
}
void HistoryWidget::setupUnreadMentionsButtonContextMenu(not_null<Ui::RpWidget*> button) {
const auto menu = std::make_shared<base::unique_qptr<Ui::PopupMenu>>();
const auto showMenu = [=] {
*menu = base::make_unique_q<Ui::PopupMenu>(button);
(*menu)->addAction(tr::lng_context_mark_read_mentions_all(tr::now), [=] {
if (_history) {
// You must add checks for peer and peer->input validity here and everywhere else in code as well
// Store it somewhere in vector for each chat, if we don't have internet connection check if request already exists in vector,
// you can either drop and replace or simply put it inside if
// Delete this comments when you end
_history->session().api().request(MTPmessages_ReadMentions(_history->peer->input)).send();
}
});
(*menu)->popup(QCursor::pos());
return true;
};
base::install_event_filter(button, [=](not_null<QEvent*> e) {
if (e->type() == QEvent::ContextMenu && showMenu()) {
return base::EventFilterResult::Cancel;
}
return base::EventFilterResult::Continue;
});
}
HistoryWidget::~HistoryWidget() {
if (_history) {
// Saving a draft on account switching.

View file

@ -597,6 +597,8 @@ private:
bool kbWasHidden() const;
void setupUnreadMentionsButtonContextMenu(not_null<Ui::RpWidget*> button);
MTP::Sender _api;
MsgId _replyToId = 0;
Ui::Text::String _replyToName;