Skip to content

Commit

Permalink
Allow sending star reactions to discussion roots.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Aug 15, 2024
1 parent 7d52c13 commit a4ac00a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/history/history_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2533,7 +2533,7 @@ bool HistoryItem::canReact() const {

void HistoryItem::addPaidReaction(int count, bool anonymous) {
Expects(count >= 0);
Expects(_history->peer->isBroadcast());
Expects(_history->peer->isBroadcast() || isDiscussionPost());

if (!_reactions) {
_reactions = std::make_unique<Data::MessageReactions>(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ For license and copyright information please follow this link:
#include "api/api_who_reacted.h"
#include "api/api_views.h"
#include "layout/layout_selection.h"
#include "payments/payments_reaction_process.h"
#include "window/section_widget.h"
#include "window/window_adaptive.h"
#include "window/window_session_controller.h"
Expand Down Expand Up @@ -2801,6 +2802,13 @@ void ListWidget::reactionChosen(ChosenReaction reaction) {
const auto item = session().data().message(reaction.context);
if (!item) {
return;
} else if (reaction.id.paid()) {
Payments::ShowPaidReactionDetails(
controller(),
item,
viewForItem(item),
HistoryReactionSource::Selector);
return;
} else if (_delegate->listShowReactPremiumError(item, reaction.id)) {
if (_menu) {
_menu->hideMenu();
Expand Down
8 changes: 6 additions & 2 deletions Telegram/SourceFiles/payments/payments_reaction_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ For license and copyright information please follow this link:
#include "boxes/send_credits_box.h" // CreditsEmojiSmall.
#include "core/ui_integration.h" // MarkedTextContext.
#include "data/components/credits.h"
#include "data/data_channel.h"
#include "data/data_message_reactions.h"
#include "data/data_session.h"
#include "data/data_user.h"
Expand Down Expand Up @@ -120,7 +121,8 @@ void ShowPaidReactionDetails(
not_null<HistoryItem*> item,
HistoryView::Element *view,
HistoryReactionSource source) {
Expects(item->history()->peer->isBroadcast());
Expects(item->history()->peer->isBroadcast()
|| item->isDiscussionPost());

const auto show = controller->uiShow();
const auto itemId = item->fullId();
Expand Down Expand Up @@ -229,11 +231,13 @@ void ShowPaidReactionDetails(
}
ranges::sort(top, ranges::greater(), &Ui::PaidReactionTop::count);

const auto linked = item->discussionPostOriginalSender();
const auto channel = (linked ? linked : item->history()->peer.get());
state->selectBox = show->show(Ui::MakePaidReactionBox({
.chosen = chosen,
.max = max,
.top = std::move(top),
.channel = item->history()->peer->name(),
.channel = channel->name(),
.submit = std::move(submitText),
.balanceValue = session->credits().balanceValue(),
.send = [=](int count, bool anonymous) {
Expand Down

0 comments on commit a4ac00a

Please sign in to comment.