Skip to content

Commit 9a9605a

Browse files
committed
Fix some issues for 1.8.38.
1 parent 6e902c5 commit 9a9605a

8 files changed

Lines changed: 104 additions & 0 deletions

File tree

Telegram/SourceFiles/history/history_item.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,11 @@ void HistoryItem::setServiceText(PreparedServiceText &&prepared) {
13331333
_text = std::move(prepared.text);
13341334
data->textLinks = std::move(prepared.links);
13351335
if (had) {
1336+
#if 0 // mtp
13361337
_history->owner().requestItemTextRefresh(this);
1338+
#endif
1339+
// Media could be updated as well which requires to recreate views.
1340+
_history->owner().requestItemViewRefresh(this);
13371341
}
13381342
}
13391343

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

1842+
void HistoryItem::ensurePropertiesLoaded() {
1843+
if (!isRegular() || (_flags & MessageFlag::PropertiesLoaded)) {
1844+
return;
1845+
}
1846+
_flags |= MessageFlag::PropertiesLoaded;
1847+
const auto id = fullId();
1848+
const auto session = &history()->session();
1849+
session->sender().request(TLgetMessageProperties(
1850+
peerToTdbChat(id.peer),
1851+
tl_int53(id.msg.bare)
1852+
)).done([=](const TLDmessageProperties &data) {
1853+
if (const auto that = session->data().message(id)) {
1854+
that->_flags |= MessageFlag::PropertiesLoaded;
1855+
// data.vcan_be_copied_to_secret_chat()
1856+
// data.vcan_be_deleted_only_for_self()
1857+
if (data.vcan_be_deleted_for_all_users().v) {
1858+
that->_flags |= MessageFlag::CanDeleteForAll;
1859+
}
1860+
if (data.vcan_be_edited().v) {
1861+
that->_flags |= MessageFlag::CanEdit;
1862+
}
1863+
// data.vcan_be_forwarded()
1864+
// data.vcan_be_paid()
1865+
// data.vcan_be_pinned()
1866+
// data.vcan_be_replied()
1867+
// data.vcan_be_replied_in_another_chat()
1868+
// data.vcan_be_saved()
1869+
// data.vcan_be_shared_in_story()
1870+
// data.vcan_edit_scheduling_state()
1871+
// data.vcan_get_embedding_code()
1872+
// data.vcan_get_link()
1873+
// data.vcan_get_media_timestamp_links()
1874+
// data.vcan_get_message_thread()
1875+
// data.vcan_get_read_date()
1876+
// data.vcan_get_statistics()
1877+
// data.vcan_get_viewers()
1878+
// data.vcan_recognize_speech()
1879+
// data.vcan_report_chat()
1880+
// data.vcan_report_reactions()
1881+
// data.vcan_report_supergroup_spam()
1882+
// data.vcan_set_fact_check()
1883+
// data.vneed_show_statistics()
1884+
}
1885+
}).send();
1886+
}
1887+
18381888
void HistoryItem::destroy() {
18391889
_history->destroyMessage(this);
18401890
}
@@ -5115,6 +5165,24 @@ void HistoryItem::setServiceMessageByContent(
51155165
lt_from,
51165166
fromLinkText(), // Link 1.
51175167
Ui::Text::WithEntities);
5168+
}, [&](const TLDmessageGiveawayCompleted &data) {
5169+
const auto winners = data.vwinner_count().v;
5170+
const auto unclaimed = data.vunclaimed_prize_count().v;
5171+
const auto credits = data.vis_star_giveaway().v;
5172+
prepared.text = {
5173+
(!winners
5174+
? tr::lng_action_giveaway_results_none(tr::now)
5175+
: (credits && unclaimed)
5176+
? tr::lng_action_giveaway_results_credits_some(tr::now)
5177+
: (!credits && unclaimed)
5178+
? tr::lng_action_giveaway_results_some(tr::now)
5179+
: (credits && !unclaimed)
5180+
? tr::lng_action_giveaway_results_credits(
5181+
tr::now,
5182+
lt_count,
5183+
winners)
5184+
: tr::lng_action_giveaway_results(tr::now, lt_count, winners))
5185+
};
51185186
}, [&](const TLDmessageForumTopicCreated &data) {
51195187
const auto topicUrl = u"internal:url:https://t.me/c/%1/%2"_q
51205188
.arg(peerToChannel(history()->peer->id).bare)
@@ -5699,6 +5767,10 @@ std::unique_ptr<Data::Media> HistoryItem::CreateMedia(
56995767
return std::make_unique<Data::MediaGiveawayResults>(
57005768
item,
57015769
Data::ComputeGiveawayResultsData(item, data));
5770+
}, [&](const TLDmessagePaidMedia &media) -> Result {
5771+
return std::make_unique<Data::MediaInvoice>(
5772+
item,
5773+
Data::ComputeInvoiceData(item, media));
57025774
}, [](const auto &) -> Result {
57035775
return nullptr;
57045776
});

Telegram/SourceFiles/history/history_item.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ class HistoryItem final : public RuntimeComposer<HistoryItem> {
245245
void setRealShortcutId(BusinessShortcutId id);
246246
void setCustomServiceLink(ClickHandlerPtr link);
247247

248+
[[nodiscard]] void ensurePropertiesLoaded();
249+
248250
void addLogEntryOriginal(
249251
WebPageId localId,
250252
const QString &label,

Telegram/SourceFiles/history/view/history_view_message.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,7 @@ void Message::draw(Painter &p, const PaintContext &context) const {
11141114
item->history()->session().factchecks().requestFor(item);
11151115
}
11161116
#endif
1117+
item->ensurePropertiesLoaded();
11171118

11181119
const auto stm = context.messageStyle();
11191120
const auto bubble = drawBubble();

Telegram/SourceFiles/history/view/history_view_service_message.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,8 @@ void Service::draw(Painter &p, const PaintContext &context) const {
501501
}
502502
const auto &margin = st::msgServiceMargin;
503503

504+
data()->ensurePropertiesLoaded();
505+
504506
const auto st = context.st;
505507
auto height = this->height() - margin.top() - margin.bottom();
506508
auto dateh = 0;

Telegram/SourceFiles/overview/overview_layout.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ ItemBase::ItemBase(
162162
: _delegate(delegate)
163163
, _parent(parent)
164164
, _dateTime(ItemDateTime(parent)) {
165+
_parent->ensurePropertiesLoaded();
165166
}
166167

167168
ItemBase::~ItemBase() = default;

Telegram/SourceFiles/payments/payments_form.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,35 @@ Form::Form(InvoiceId id, bool receipt)
302302
if (_receiptMode) {
303303
_invoice.receipt.paid = true;
304304
requestReceipt();
305+
} else if (v::is<InvoiceStarGift>(id.value)) {
306+
crl::on_main(this, [=] {
307+
sendStarGiftForm();
308+
});
305309
} else {
306310
requestForm();
307311
}
308312
}
309313

310314
Form::~Form() = default;
311315

316+
void Form::sendStarGiftForm() {
317+
const auto &gift = v::get<InvoiceStarGift>(_id.value);
318+
const auto invoice = InvoiceCredits{
319+
.session = _session,
320+
.randomId = 0,
321+
.credits = uint64(gift.stars),
322+
.currency = ::Ui::kCreditsCurrency,
323+
.amount = uint64(gift.stars),
324+
};
325+
const auto formData = CreditsFormData{
326+
.id = _id,
327+
.invoice = invoice,
328+
.starGiftLimitedCount = gift.limitedCount,
329+
.starGiftForm = true,
330+
};
331+
_updates.fire(CreditsPaymentStarted{ .data = formData });
332+
}
333+
312334
void Form::fillInvoiceFromMessage() {
313335
const auto message = std::get_if<InvoiceMessage>(&_id.value);
314336
if (!message) {

Telegram/SourceFiles/payments/payments_form.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ struct InvoiceCredits {
194194

195195
struct InvoiceStarGift {
196196
uint64 giftId = 0;
197+
int64 stars = 0;
197198
uint64 randomId = 0;
198199
TextWithEntities message;
199200
not_null<UserData*> user;
@@ -411,6 +412,7 @@ class Form final : public base::has_weak_ptr {
411412
void fillStripeNativeMethod(QJsonObject object);
412413
void fillSmartGlocalNativeMethod(QJsonObject object);
413414
#endif
415+
void sendStarGiftForm();
414416
void refreshPaymentMethodDetails();
415417
void refreshSavedPaymentMethodDetails();
416418
[[nodiscard]] QString defaultPhone() const;

Telegram/SourceFiles/ui/effects/credits_graphics.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,8 @@ PaintRoundImageCallback GenerateGiftStickerUserpicCallback(
442442
not_null<Main::Session*> session,
443443
uint64 stickerId,
444444
Fn<void()> update) {
445+
Expects(stickerId != 0);
446+
445447
struct State {
446448
std::optional<UserpicBuilder::PreviewPainter> painter;
447449
int size = 0;

0 commit comments

Comments
 (0)