mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Respect can_see_list flag in reactions.
This commit is contained in:
parent
118072db77
commit
fe468ce7e9
9 changed files with 22 additions and 12 deletions
|
@ -309,6 +309,10 @@ bool WhoReadExists(not_null<HistoryItem*> item) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WhoReactedExists(not_null<HistoryItem*> item) {
|
||||||
|
return item->canViewReactions() || WhoReadExists(item);
|
||||||
|
}
|
||||||
|
|
||||||
rpl::producer<Ui::WhoReadContent> WhoRead(
|
rpl::producer<Ui::WhoReadContent> WhoRead(
|
||||||
not_null<HistoryItem*> item,
|
not_null<HistoryItem*> item,
|
||||||
not_null<QWidget*> context,
|
not_null<QWidget*> context,
|
||||||
|
|
|
@ -20,6 +20,7 @@ struct WhoReadContent;
|
||||||
namespace Api {
|
namespace Api {
|
||||||
|
|
||||||
[[nodiscard]] bool WhoReadExists(not_null<HistoryItem*> item);
|
[[nodiscard]] bool WhoReadExists(not_null<HistoryItem*> item);
|
||||||
|
[[nodiscard]] bool WhoReactedExists(not_null<HistoryItem*> item);
|
||||||
|
|
||||||
// The context must be destroyed before the session holding this item.
|
// The context must be destroyed before the session holding this item.
|
||||||
[[nodiscard]] rpl::producer<Ui::WhoReadContent> WhoRead(
|
[[nodiscard]] rpl::producer<Ui::WhoReadContent> WhoRead(
|
||||||
|
|
|
@ -3687,9 +3687,6 @@ void ApiWrap::sendInlineResult(
|
||||||
if (silentPost) {
|
if (silentPost) {
|
||||||
sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_silent;
|
sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_silent;
|
||||||
}
|
}
|
||||||
if (bot) {
|
|
||||||
flags |= MessageFlag::HasViaBot;
|
|
||||||
}
|
|
||||||
if (action.options.scheduled) {
|
if (action.options.scheduled) {
|
||||||
flags |= MessageFlag::IsOrWasScheduled;
|
flags |= MessageFlag::IsOrWasScheduled;
|
||||||
sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_schedule_date;
|
sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_schedule_date;
|
||||||
|
|
|
@ -227,7 +227,7 @@ enum class MessageFlag : uint32 {
|
||||||
HasPostAuthor = (1U << 4),
|
HasPostAuthor = (1U << 4),
|
||||||
HasViews = (1U << 5),
|
HasViews = (1U << 5),
|
||||||
HasReplyInfo = (1U << 6),
|
HasReplyInfo = (1U << 6),
|
||||||
HasViaBot = (1U << 7),
|
CanViewReactions = (1U << 7),
|
||||||
AdminLogEntry = (1U << 8),
|
AdminLogEntry = (1U << 8),
|
||||||
Post = (1U << 9),
|
Post = (1U << 9),
|
||||||
Silent = (1U << 10),
|
Silent = (1U << 10),
|
||||||
|
|
|
@ -1702,7 +1702,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto hasWhoReadItem = _dragStateItem
|
const auto hasWhoReadItem = _dragStateItem
|
||||||
&& Api::WhoReadExists(_dragStateItem);
|
&& Api::WhoReactedExists(_dragStateItem);
|
||||||
_menu = base::make_unique_q<Ui::PopupMenu>(
|
_menu = base::make_unique_q<Ui::PopupMenu>(
|
||||||
this,
|
this,
|
||||||
hasWhoReadItem ? st::whoReadMenu : st::popupMenuWithIcons);
|
hasWhoReadItem ? st::whoReadMenu : st::popupMenuWithIcons);
|
||||||
|
|
|
@ -773,6 +773,11 @@ void HistoryItem::toggleReaction(const QString &reaction) {
|
||||||
|
|
||||||
void HistoryItem::updateReactions(const MTPMessageReactions &reactions) {
|
void HistoryItem::updateReactions(const MTPMessageReactions &reactions) {
|
||||||
reactions.match([&](const MTPDmessageReactions &data) {
|
reactions.match([&](const MTPDmessageReactions &data) {
|
||||||
|
if (data.is_can_see_list()) {
|
||||||
|
_flags |= MessageFlag::CanViewReactions;
|
||||||
|
} else {
|
||||||
|
_flags &= ~MessageFlag::CanViewReactions;
|
||||||
|
}
|
||||||
if (data.vresults().v.isEmpty()) {
|
if (data.vresults().v.isEmpty()) {
|
||||||
_reactions = nullptr;
|
_reactions = nullptr;
|
||||||
return;
|
return;
|
||||||
|
@ -789,6 +794,12 @@ const base::flat_map<QString, int> &HistoryItem::reactions() const {
|
||||||
return _reactions ? _reactions->list() : kEmpty;
|
return _reactions ? _reactions->list() : kEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HistoryItem::canViewReactions() const {
|
||||||
|
return (_flags & MessageFlag::CanViewReactions)
|
||||||
|
&& _reactions
|
||||||
|
&& !_reactions->list().empty();
|
||||||
|
}
|
||||||
|
|
||||||
QString HistoryItem::chosenReaction() const {
|
QString HistoryItem::chosenReaction() const {
|
||||||
return _reactions ? _reactions->chosen() : QString();
|
return _reactions ? _reactions->chosen() : QString();
|
||||||
}
|
}
|
||||||
|
@ -1138,7 +1149,6 @@ MessageFlags FlagsFromMTP(
|
||||||
| ((flags & MTP::f_edit_hide) ? Flag::HideEdited : Flag())
|
| ((flags & MTP::f_edit_hide) ? Flag::HideEdited : Flag())
|
||||||
| ((flags & MTP::f_pinned) ? Flag::Pinned : Flag())
|
| ((flags & MTP::f_pinned) ? Flag::Pinned : Flag())
|
||||||
| ((flags & MTP::f_from_id) ? Flag::HasFromId : Flag())
|
| ((flags & MTP::f_from_id) ? Flag::HasFromId : Flag())
|
||||||
| ((flags & MTP::f_via_bot_id) ? Flag::HasViaBot : Flag())
|
|
||||||
| ((flags & MTP::f_reply_to) ? Flag::HasReplyInfo : Flag())
|
| ((flags & MTP::f_reply_to) ? Flag::HasReplyInfo : Flag())
|
||||||
| ((flags & MTP::f_reply_markup) ? Flag::HasReplyMarkup : Flag())
|
| ((flags & MTP::f_reply_markup) ? Flag::HasReplyMarkup : Flag())
|
||||||
| ((flags & MTP::f_from_scheduled) ? Flag::IsOrWasScheduled : Flag())
|
| ((flags & MTP::f_from_scheduled) ? Flag::IsOrWasScheduled : Flag())
|
||||||
|
|
|
@ -396,6 +396,7 @@ public:
|
||||||
void toggleReaction(const QString &reaction);
|
void toggleReaction(const QString &reaction);
|
||||||
void updateReactions(const MTPMessageReactions &reactions);
|
void updateReactions(const MTPMessageReactions &reactions);
|
||||||
[[nodiscard]] const base::flat_map<QString, int> &reactions() const;
|
[[nodiscard]] const base::flat_map<QString, int> &reactions() const;
|
||||||
|
[[nodiscard]] bool canViewReactions() const;
|
||||||
[[nodiscard]] QString chosenReaction() const;
|
[[nodiscard]] QString chosenReaction() const;
|
||||||
|
|
||||||
[[nodiscard]] bool hasDirectLink() const;
|
[[nodiscard]] bool hasDirectLink() const;
|
||||||
|
@ -476,7 +477,7 @@ protected:
|
||||||
void finishEditionToEmpty();
|
void finishEditionToEmpty();
|
||||||
|
|
||||||
const not_null<History*> _history;
|
const not_null<History*> _history;
|
||||||
not_null<PeerData*> _from;
|
const not_null<PeerData*> _from;
|
||||||
MessageFlags _flags = 0;
|
MessageFlags _flags = 0;
|
||||||
|
|
||||||
void invalidateChatListEntry();
|
void invalidateChatListEntry();
|
||||||
|
|
|
@ -64,9 +64,6 @@ namespace {
|
||||||
if (from) {
|
if (from) {
|
||||||
result |= MessageFlag::HasFromId;
|
result |= MessageFlag::HasFromId;
|
||||||
}
|
}
|
||||||
if (fwd->Has<HistoryMessageVia>()) {
|
|
||||||
result |= MessageFlag::HasViaBot;
|
|
||||||
}
|
|
||||||
if (const auto media = fwd->media()) {
|
if (const auto media = fwd->media()) {
|
||||||
if ((!peer->isChannel() || peer->isMegagroup())
|
if ((!peer->isChannel() || peer->isMegagroup())
|
||||||
&& media->forwardedBecomesUnread()) {
|
&& media->forwardedBecomesUnread()) {
|
||||||
|
@ -777,7 +774,7 @@ void HistoryMessage::createComponentsHelper(
|
||||||
const QString &postAuthor,
|
const QString &postAuthor,
|
||||||
HistoryMessageMarkupData &&markup) {
|
HistoryMessageMarkupData &&markup) {
|
||||||
auto config = CreateConfig();
|
auto config = CreateConfig();
|
||||||
if (flags & MessageFlag::HasViaBot) config.viaBotId = viaBotId;
|
config.viaBotId = viaBotId;
|
||||||
if (flags & MessageFlag::HasReplyInfo) {
|
if (flags & MessageFlag::HasReplyInfo) {
|
||||||
config.replyTo = replyTo;
|
config.replyTo = replyTo;
|
||||||
const auto replyToTop = LookupReplyToTop(history(), replyTo);
|
const auto replyToTop = LookupReplyToTop(history(), replyTo);
|
||||||
|
|
|
@ -410,7 +410,7 @@ rpl::producer<int> FullReactionsCountValue(
|
||||||
) | rpl::then(
|
) | rpl::then(
|
||||||
reactions->updates()
|
reactions->updates()
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return int(reactions->list().size());
|
return int(reactions->list(Data::Reactions::Type::Active).size());
|
||||||
}) | rpl::distinct_until_changed();
|
}) | rpl::distinct_until_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue