Added support of pending suggestion to set up login email.
This commit is contained in:
@@ -120,7 +120,39 @@ Session::Session(
|
||||
, _factchecks(std::make_unique<Data::Factchecks>(this))
|
||||
, _locationPickers(std::make_unique<Data::LocationPickers>())
|
||||
, _credits(std::make_unique<Data::Credits>(this))
|
||||
, _promoSuggestions(std::make_unique<Data::PromoSuggestions>(this))
|
||||
, _promoSuggestions(std::make_unique<Data::PromoSuggestions>(this, [=] {
|
||||
using State = Data::SetupEmailState;
|
||||
if (_promoSuggestions->setupEmailState() == State::Setup
|
||||
|| _promoSuggestions->setupEmailState() == State::SetupNoSkip) {
|
||||
if (_settings->setupEmailState() == State::Setup
|
||||
|| _settings->setupEmailState() == State::SetupNoSkip) {
|
||||
crl::on_main([=] {
|
||||
// base::call_delayed(5000, [=] {
|
||||
Core::App().lockBySetupEmail();
|
||||
});
|
||||
const auto unlockLifetime = std::make_shared<rpl::lifetime>();
|
||||
_promoSuggestions->setupEmailStateValue(
|
||||
) | rpl::filter([](Data::SetupEmailState s) {
|
||||
return s == Data::SetupEmailState::None;
|
||||
}) | rpl::take(1) | rpl::start_with_next(crl::guard(this, [=] {
|
||||
Core::App().unlockSetupEmail();
|
||||
_settings->setSetupEmailState(State::None);
|
||||
saveSettingsDelayed(200);
|
||||
unlockLifetime->destroy();
|
||||
}), *unlockLifetime);
|
||||
} else {
|
||||
_settings->setSetupEmailState(
|
||||
_promoSuggestions->setupEmailState());
|
||||
saveSettingsDelayed(200);
|
||||
}
|
||||
} else {
|
||||
if (_settings->setupEmailState() == State::Setup
|
||||
|| _settings->setupEmailState() == State::SetupNoSkip) {
|
||||
_settings->setSetupEmailState(State::None);
|
||||
saveSettingsDelayed(200);
|
||||
}
|
||||
}
|
||||
}))
|
||||
, _cachedReactionIconFactory(std::make_unique<ReactionIconFactory>())
|
||||
, _supportHelper(Support::Helper::Create(this))
|
||||
, _fastButtonsBots(std::make_unique<Support::FastButtonsBots>(this))
|
||||
|
||||
@@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "boxes/send_files_box.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "data/components/promo_suggestions.h"
|
||||
|
||||
namespace Main {
|
||||
namespace {
|
||||
@@ -28,7 +29,8 @@ constexpr auto kVersion = 2;
|
||||
|
||||
SessionSettings::SessionSettings()
|
||||
: _selectorTab(ChatHelpers::SelectorTab::Emoji)
|
||||
, _supportSwitch(Support::SwitchSettings::Next) {
|
||||
, _supportSwitch(Support::SwitchSettings::Next)
|
||||
, _setupEmailState(Data::SetupEmailState::None) {
|
||||
}
|
||||
|
||||
QByteArray SessionSettings::serialize() const {
|
||||
@@ -63,6 +65,7 @@ QByteArray SessionSettings::serialize() const {
|
||||
+ Serialize::stringSize(auth.device)
|
||||
+ Serialize::stringSize(auth.location);
|
||||
}
|
||||
size += sizeof(qint32); // _setupEmailState
|
||||
|
||||
auto result = QByteArray();
|
||||
result.reserve(size);
|
||||
@@ -143,6 +146,7 @@ QByteArray SessionSettings::serialize() const {
|
||||
<< auth.device
|
||||
<< auth.location;
|
||||
}
|
||||
stream << qint32(static_cast<int>(_setupEmailState));
|
||||
}
|
||||
|
||||
Ensures(result.size() == size);
|
||||
@@ -214,6 +218,7 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
||||
base::flat_map<ThreadId, ushort> ringtoneVolumes;
|
||||
base::flat_set<uint64> ratedTranscriptions;
|
||||
std::vector<Data::UnreviewedAuth> unreviewed;
|
||||
qint32 setupEmailState = 0;
|
||||
|
||||
stream >> versionTag;
|
||||
if (versionTag == kVersionTag) {
|
||||
@@ -627,6 +632,9 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
stream >> setupEmailState;
|
||||
}
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for SessionSettings::addFromSerialized()"));
|
||||
@@ -678,6 +686,17 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
||||
_ringtoneVolumes = std::move(ringtoneVolumes);
|
||||
_ratedTranscriptions = std::move(ratedTranscriptions);
|
||||
_unreviewed = std::move(unreviewed);
|
||||
auto uncheckedSetupEmailState = static_cast<Data::SetupEmailState>(
|
||||
setupEmailState);
|
||||
switch (uncheckedSetupEmailState) {
|
||||
case Data::SetupEmailState::None:
|
||||
case Data::SetupEmailState::Setup:
|
||||
case Data::SetupEmailState::SetupNoSkip:
|
||||
case Data::SetupEmailState::SettingUp:
|
||||
case Data::SetupEmailState::SettingUpNoSkip:
|
||||
_setupEmailState = uncheckedSetupEmailState;
|
||||
break;
|
||||
}
|
||||
|
||||
if (version < 2) {
|
||||
app.setLastSeenWarningSeen(appLastSeenWarningSeen == 1);
|
||||
@@ -906,4 +925,12 @@ const std::vector<Data::UnreviewedAuth> &SessionSettings::unreviewed() const {
|
||||
return _unreviewed;
|
||||
}
|
||||
|
||||
void SessionSettings::setSetupEmailState(Data::SetupEmailState state) {
|
||||
_setupEmailState = state;
|
||||
}
|
||||
|
||||
Data::SetupEmailState SessionSettings::setupEmailState() const {
|
||||
return _setupEmailState;
|
||||
}
|
||||
|
||||
} // namespace Main
|
||||
|
||||
@@ -20,6 +20,10 @@ namespace ChatHelpers {
|
||||
enum class SelectorTab;
|
||||
} // namespace ChatHelpers
|
||||
|
||||
namespace Data {
|
||||
enum class SetupEmailState;
|
||||
} // namespace Data
|
||||
|
||||
namespace Main {
|
||||
|
||||
class SessionSettings final {
|
||||
@@ -169,6 +173,9 @@ public:
|
||||
void setUnreviewed(std::vector<Data::UnreviewedAuth> auths);
|
||||
[[nodiscard]] const std::vector<Data::UnreviewedAuth> &unreviewed() const;
|
||||
|
||||
void setSetupEmailState(Data::SetupEmailState state);
|
||||
[[nodiscard]] Data::SetupEmailState setupEmailState() const;
|
||||
|
||||
private:
|
||||
static constexpr auto kDefaultSupportChatsLimitSlice = 7 * 24 * 60 * 60;
|
||||
static constexpr auto kPhotoEditorHintMaxShowsCount = 5;
|
||||
@@ -213,6 +220,8 @@ private:
|
||||
|
||||
std::vector<Data::UnreviewedAuth> _unreviewed;
|
||||
|
||||
Data::SetupEmailState _setupEmailState;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Main
|
||||
|
||||
Reference in New Issue
Block a user