ZaStoGram_desktop/Telegram/SourceFiles/data/components/promo_suggestions.h
loop-uh 0fd5d76a67 Merge upstream v7.3.1
Слияние с tdesktop от 64ca5475f2 до тега v7.3.1 (7.2.10 beta, 7.3, 7.3.1).

- Версия 7.3.1 (7003001), BetaChannel 0, комментарий ZaStoGram сохранён.
- Обновлятор: оригинал убрал пакеты v1 (RSA), а наш Packer и Forgejo
  выпускают именно их. v1 оставлен как UnpackUpdateV1 рядом с v2 и
  использует новые проверенные распаковку и извлечение файлов.
- mtproto: исправления импорта авторизации из оригинала перенесены в нашу
  структуру RequestRegistry; пути include новых файлов кошелька
  приведены к нашей раскладке mtproto/.
- prepare.py: стадии оригинала (ucrt64, ffmpeg 8, openssl 3.5, libheif,
  Rust, wallet-engine) с нашими skip-debug и patches_extra.
- lib_ui, lib_lottie: форки слиты с версиями из v7.3.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 21:43:47 +03:00

120 lines
3.1 KiB
C++

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "base/timer.h"
class History;
namespace Main {
class Session;
} // namespace Main
namespace Data {
enum class SetupEmailState {
None,
Setup,
SetupNoSkip,
SettingUp,
SettingUpNoSkip,
};
struct CustomSuggestion final {
QString suggestion;
TextWithEntities title;
TextWithEntities description;
QString url;
friend inline auto operator<=>(
const CustomSuggestion &,
const CustomSuggestion &) = default;
};
class PromoSuggestions final {
public:
explicit PromoSuggestions(
not_null<Main::Session*> session,
Fn<void()> firstPromoLoaded = nullptr);
~PromoSuggestions();
[[nodiscard]] bool current(const QString &key) const;
[[nodiscard]] std::optional<CustomSuggestion> custom() const;
[[nodiscard]] rpl::producer<> requested(const QString &key) const;
void dismiss(const QString &key);
void dismissSetupEmail(Fn<void()> done);
void refreshTopPromotion();
void invalidate();
rpl::producer<> value() const;
// Create rpl::producer<> refreshed() const; on memand.
void requestContactBirthdays(Fn<void()> done, bool force = false);
[[nodiscard]] auto knownContactBirthdays() const
-> std::optional<std::vector<UserId>>;
[[nodiscard]] auto knownBirthdaysToday() const
-> std::optional<std::vector<UserId>>;
[[nodiscard]] static QString SugValidatePassword();
[[nodiscard]] static QString SugWalletFirstIncomingTransfer();
void setSetupEmailState(SetupEmailState state);
[[nodiscard]] SetupEmailState setupEmailState() const;
[[nodiscard]] rpl::producer<SetupEmailState> setupEmailStateValue() const;
private:
void setTopPromoted(
History *promoted,
const QString &type,
const QString &message);
// ZaStoGram: the promoted dialog is always our own channel,
// never the proxy-sponsor peer sent by the server.
void promoteCustomChannel();
// ZaStoGram: we are not subscribed to the promoted channel, so the
// server pushes no updates for it - its chat list row has to be polled.
void refreshCustomChannelEntry();
void topPromotionDelayed(TimeId now, TimeId next);
const not_null<Main::Session*> _session;
base::flat_set<QString> _dismissedSuggestions;
std::vector<QString> _pendingSuggestions;
std::optional<CustomSuggestion> _custom;
History *_topPromoted = nullptr;
History *_customChannel = nullptr;
mtpRequestId _customChannelRequestId = 0;
base::Timer _customChannelTimer;
mtpRequestId _contactBirthdaysRequestId = 0;
int _contactBirthdaysLastDayRequest = -1;
std::vector<UserId> _contactBirthdays;
std::vector<UserId> _contactBirthdaysToday;
mtpRequestId _topPromotionRequestId = 0;
std::pair<QString, uint32> _topPromotionKey;
TimeId _topPromotionNextRequestTime = TimeId(0);
base::Timer _topPromotionTimer;
SetupEmailState _setupEmailState = SetupEmailState::None;
rpl::event_stream<> _refreshed;
rpl::event_stream<SetupEmailState> _setupEmailStateChanges;
Fn<void()> _firstPromoLoaded;
rpl::lifetime _lifetime;
};
} // namespace Data