mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Mark all reactions as read context menu.
This commit is contained in:
@@ -15,7 +15,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_session.h"
|
||||
#include "main/main_session.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_unread_things.h"
|
||||
#include "apiwrap.h"
|
||||
#include "styles/style_menu_icons.h"
|
||||
|
||||
@@ -143,9 +146,11 @@ void SetupMenuAndShortcuts(
|
||||
}, button->lifetime());
|
||||
}
|
||||
|
||||
void SetupUnreadMentionsMenu(
|
||||
void SetupReadAllMenu(
|
||||
not_null<Ui::RpWidget*> button,
|
||||
Fn<PeerData*()> currentPeer) {
|
||||
Fn<PeerData*()> currentPeer,
|
||||
const QString &text,
|
||||
Fn<void(not_null<PeerData*>, Fn<void()>)> sendReadRequest) {
|
||||
struct State {
|
||||
base::unique_qptr<Ui::PopupMenu> menu;
|
||||
base::flat_set<not_null<PeerData*>> sentForPeers;
|
||||
@@ -159,19 +164,11 @@ void SetupUnreadMentionsMenu(
|
||||
state->menu = base::make_unique_q<Ui::PopupMenu>(
|
||||
button,
|
||||
st::popupMenuWithIcons);
|
||||
const auto text = tr::lng_context_mark_read_mentions_all(tr::now);
|
||||
state->menu->addAction(text, [=] {
|
||||
if (!state->sentForPeers.emplace(peer).second) {
|
||||
return;
|
||||
}
|
||||
peer->session().api().request(MTPmessages_ReadMentions(
|
||||
peer->input
|
||||
)).done([=](const MTPmessages_AffectedHistory &result) {
|
||||
state->sentForPeers.remove(peer);
|
||||
peer->session().api().applyAffectedHistory(peer, result);
|
||||
}).fail([=] {
|
||||
state->sentForPeers.remove(peer);
|
||||
}).send();
|
||||
sendReadRequest(peer, [=] { state->sentForPeers.remove(peer); });
|
||||
}, &st::menuIconMarkRead);
|
||||
state->menu->popup(QCursor::pos());
|
||||
};
|
||||
@@ -185,9 +182,36 @@ void SetupUnreadMentionsMenu(
|
||||
});
|
||||
}
|
||||
|
||||
void SetupUnreadMentionsMenu(
|
||||
not_null<Ui::RpWidget*> button,
|
||||
Fn<PeerData*()> currentPeer) {
|
||||
const auto text = tr::lng_context_mark_read_mentions_all(tr::now);
|
||||
const auto sendRequest = [=](not_null<PeerData*> peer, Fn<void()> done) {
|
||||
peer->session().api().request(MTPmessages_ReadMentions(
|
||||
peer->input
|
||||
)).done([=](const MTPmessages_AffectedHistory &result) {
|
||||
done();
|
||||
peer->session().api().applyAffectedHistory(peer, result);
|
||||
peer->owner().history(peer)->unreadMentions().clear();
|
||||
}).fail(done).send();
|
||||
};
|
||||
SetupReadAllMenu(button, currentPeer, text, sendRequest);
|
||||
}
|
||||
|
||||
void SetupUnreadReactionsMenu(
|
||||
not_null<Ui::RpWidget*> button,
|
||||
Fn<PeerData*()> currentPeer) {
|
||||
const auto text = tr::lng_context_mark_read_reactions_all(tr::now);
|
||||
const auto sendRequest = [=](not_null<PeerData*> peer, Fn<void()> done) {
|
||||
peer->session().api().request(MTPmessages_ReadReactions(
|
||||
peer->input
|
||||
)).done([=](const MTPmessages_AffectedHistory &result) {
|
||||
done();
|
||||
peer->session().api().applyAffectedHistory(peer, result);
|
||||
peer->owner().history(peer)->unreadReactions().clear();
|
||||
}).fail(done).send();
|
||||
};
|
||||
SetupReadAllMenu(button, currentPeer, text, sendRequest);
|
||||
}
|
||||
|
||||
} // namespace SendMenu
|
||||
|
Reference in New Issue
Block a user