MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / update

Method update

Telegram/SourceFiles/boxes/star_gift_box.cpp:3631–3666  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3629}
3630
3631void UpgradePriceValue::update() {
3632 if (_all.empty() || _next.empty()) {
3633 _timer.cancel();
3634 return;
3635 }
3636 const auto now = base::unixtime::now();
3637 const auto i = ranges::upper_bound(
3638 _all,
3639 now,
3640 ranges::less(),
3641 &UpgradePrice::date);
3642 const auto j = ranges::upper_bound(
3643 _next,
3644 now,
3645 ranges::less(),
3646 &UpgradePrice::date);
3647 const auto full = (i == begin(_all)) ? i->stars : (i - 1)->stars;
3648 const auto part = (j == begin(_next)) ? j->stars : (j - 1)->stars;
3649 const auto fullDate = (i != end(_all)) ? i->date : TimeId();
3650 const auto partDate = (j != end(_next)) ? j->date : TimeId();
3651 _cost = std::min({ _cost.current(), part, full});
3652 if (int(end(_next) - j) < 3) {
3653 refresh();
3654 }
3655
3656 const auto next = std::min({
3657 partDate ? partDate : TimeId(INT_MAX),
3658 fullDate ? fullDate : TimeId(INT_MAX),
3659 });
3660 if (next != TimeId(INT_MAX)) {
3661 _tillNext = next - now;
3662 } else {
3663 _tillNext = 0;
3664 _timer.cancel();
3665 }
3666}
3667
3668void UpgradePriceValue::refresh() {
3669 if (_refreshing || _finished) {

Callers 15

FailureAnimationCheckFunction · 0.45
StartGiftFlightFunction · 0.45
StartGiftFlightToFaceFunction · 0.45
SetupCraftProgressTitleFunction · 0.45
StartCraftAnimationFunction · 0.45
ShowMatchCodesBoxFunction · 0.45
updateRowMethod · 0.45
applyDarkModeMethod · 0.45
UniqueGiftCoverWidgetMethod · 0.45
refreshPriceTagMethod · 0.45
pushBlockMethod · 0.45

Calls 3

emptyMethod · 0.45
cancelMethod · 0.45
currentMethod · 0.45

Tested by

no test coverage detected