Skip to content

Commit

Permalink
Fix some issues for 1.8.38.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Nov 7, 2024
1 parent 6e902c5 commit 827ee0b
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 0 deletions.
72 changes: 72 additions & 0 deletions Telegram/SourceFiles/history/history_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,11 @@ void HistoryItem::setServiceText(PreparedServiceText &&prepared) {
_text = std::move(prepared.text);
data->textLinks = std::move(prepared.links);
if (had) {
#if 0 // mtp
_history->owner().requestItemTextRefresh(this);
#endif
// Media could be updated as well which requires to recreate views.
_history->owner().requestItemViewRefresh(this);
}
}

Expand Down Expand Up @@ -1835,6 +1839,52 @@ void HistoryItem::setCustomServiceLink(ClickHandlerPtr link) {
Get<HistoryServiceCustomLink>()->link = std::move(link);
}

void HistoryItem::ensurePropertiesLoaded() {
if (!isRegular() || (_flags & MessageFlag::PropertiesLoaded)) {
return;
}
_flags |= MessageFlag::PropertiesLoaded;
const auto id = fullId();
const auto session = &history()->session();
session->sender().request(TLgetMessageProperties(
peerToTdbChat(id.peer),
tl_int53(id.msg.bare)
)).done([=](const TLDmessageProperties &data) {
if (const auto that = session->data().message(id)) {
that->_flags |= MessageFlag::PropertiesLoaded;
// data.vcan_be_copied_to_secret_chat()
// data.vcan_be_deleted_only_for_self()
if (data.vcan_be_deleted_for_all_users().v) {
that->_flags |= MessageFlag::CanDeleteForAll;
}
if (data.vcan_be_edited().v) {
that->_flags |= MessageFlag::CanEdit;
}
// data.vcan_be_forwarded()
// data.vcan_be_paid()
// data.vcan_be_pinned()
// data.vcan_be_replied()
// data.vcan_be_replied_in_another_chat()
// data.vcan_be_saved()
// data.vcan_be_shared_in_story()
// data.vcan_edit_scheduling_state()
// data.vcan_get_embedding_code()
// data.vcan_get_link()
// data.vcan_get_media_timestamp_links()
// data.vcan_get_message_thread()
// data.vcan_get_read_date()
// data.vcan_get_statistics()
// data.vcan_get_viewers()
// data.vcan_recognize_speech()
// data.vcan_report_chat()
// data.vcan_report_reactions()
// data.vcan_report_supergroup_spam()
// data.vcan_set_fact_check()
// data.vneed_show_statistics()
}
}).send();
}

void HistoryItem::destroy() {
_history->destroyMessage(this);
}
Expand Down Expand Up @@ -5115,6 +5165,24 @@ void HistoryItem::setServiceMessageByContent(
lt_from,
fromLinkText(), // Link 1.
Ui::Text::WithEntities);
}, [&](const TLDmessageGiveawayCompleted &data) {
const auto winners = data.vwinner_count().v;
const auto unclaimed = data.vunclaimed_prize_count().v;
const auto credits = data.vis_star_giveaway().v;
prepared.text = {
(!winners
? tr::lng_action_giveaway_results_none(tr::now)
: (credits && unclaimed)
? tr::lng_action_giveaway_results_credits_some(tr::now)
: (!credits && unclaimed)
? tr::lng_action_giveaway_results_some(tr::now)
: (credits && !unclaimed)
? tr::lng_action_giveaway_results_credits(
tr::now,
lt_count,
winners)
: tr::lng_action_giveaway_results(tr::now, lt_count, winners))
};
}, [&](const TLDmessageForumTopicCreated &data) {
const auto topicUrl = u"internal:url:https://t.me/c/%1/%2"_q
.arg(peerToChannel(history()->peer->id).bare)
Expand Down Expand Up @@ -5699,6 +5767,10 @@ std::unique_ptr<Data::Media> HistoryItem::CreateMedia(
return std::make_unique<Data::MediaGiveawayResults>(
item,
Data::ComputeGiveawayResultsData(item, data));
}, [&](const TLDmessagePaidMedia &media) -> Result {
return std::make_unique<Data::MediaInvoice>(
item,
Data::ComputeInvoiceData(item, media));
}, [](const auto &) -> Result {
return nullptr;
});
Expand Down
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/history/history_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ class HistoryItem final : public RuntimeComposer<HistoryItem> {
void setRealShortcutId(BusinessShortcutId id);
void setCustomServiceLink(ClickHandlerPtr link);

void ensurePropertiesLoaded();

void addLogEntryOriginal(
WebPageId localId,
const QString &label,
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/history/view/history_view_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,7 @@ void Message::draw(Painter &p, const PaintContext &context) const {
item->history()->session().factchecks().requestFor(item);
}
#endif
item->ensurePropertiesLoaded();

const auto stm = context.messageStyle();
const auto bubble = drawBubble();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ void Service::draw(Painter &p, const PaintContext &context) const {
}
const auto &margin = st::msgServiceMargin;

data()->ensurePropertiesLoaded();

const auto st = context.st;
auto height = this->height() - margin.top() - margin.bottom();
auto dateh = 0;
Expand Down
1 change: 1 addition & 0 deletions Telegram/SourceFiles/overview/overview_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ ItemBase::ItemBase(
: _delegate(delegate)
, _parent(parent)
, _dateTime(ItemDateTime(parent)) {
_parent->ensurePropertiesLoaded();
}

ItemBase::~ItemBase() = default;
Expand Down
22 changes: 22 additions & 0 deletions Telegram/SourceFiles/payments/payments_form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,35 @@ Form::Form(InvoiceId id, bool receipt)
if (_receiptMode) {
_invoice.receipt.paid = true;
requestReceipt();
} else if (v::is<InvoiceStarGift>(id.value)) {
crl::on_main(this, [=] {
sendStarGiftForm();
});
} else {
requestForm();
}
}

Form::~Form() = default;

void Form::sendStarGiftForm() {
const auto &gift = v::get<InvoiceStarGift>(_id.value);
const auto invoice = InvoiceCredits{
.session = _session,
.randomId = 0,
.credits = uint64(gift.stars),
.currency = ::Ui::kCreditsCurrency,
.amount = uint64(gift.stars),
};
const auto formData = CreditsFormData{
.id = _id,
.invoice = invoice,
.starGiftLimitedCount = gift.limitedCount,
.starGiftForm = true,
};
_updates.fire(CreditsPaymentStarted{ .data = formData });
}

void Form::fillInvoiceFromMessage() {
const auto message = std::get_if<InvoiceMessage>(&_id.value);
if (!message) {
Expand Down
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/payments/payments_form.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ struct InvoiceCredits {

struct InvoiceStarGift {
uint64 giftId = 0;
int64 stars = 0;
uint64 randomId = 0;
TextWithEntities message;
not_null<UserData*> user;
Expand Down Expand Up @@ -411,6 +412,7 @@ class Form final : public base::has_weak_ptr {
void fillStripeNativeMethod(QJsonObject object);
void fillSmartGlocalNativeMethod(QJsonObject object);
#endif
void sendStarGiftForm();
void refreshPaymentMethodDetails();
void refreshSavedPaymentMethodDetails();
[[nodiscard]] QString defaultPhone() const;
Expand Down
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/ui/effects/credits_graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ PaintRoundImageCallback GenerateGiftStickerUserpicCallback(
not_null<Main::Session*> session,
uint64 stickerId,
Fn<void()> update) {
Expects(stickerId != 0);

struct State {
std::optional<UserpicBuilder::PreviewPainter> painter;
int size = 0;
Expand Down

0 comments on commit 827ee0b

Please sign in to comment.