init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
107
Telegram/SourceFiles/data/components/promo_suggestions.h
Normal file
107
Telegram/SourceFiles/data/components/promo_suggestions.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
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();
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user