mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix app start without data.
This commit is contained in:
parent
40971d6da6
commit
cbad993bba
5 changed files with 23 additions and 15 deletions
|
@ -68,11 +68,7 @@ Storage::Domain &Account::domainLocal() const {
|
||||||
const QByteArray &passcode) {
|
const QByteArray &passcode) {
|
||||||
Expects(!_appConfig);
|
Expects(!_appConfig);
|
||||||
|
|
||||||
const auto result = _local->legacyStart(passcode);
|
return _local->legacyStart(passcode);
|
||||||
if (result == Storage::StartResult::Success) {
|
|
||||||
start(nullptr);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<MTP::Config> Account::prepareToStart(
|
std::unique_ptr<MTP::Config> Account::prepareToStart(
|
||||||
|
|
|
@ -25,6 +25,10 @@ namespace Main {
|
||||||
Domain::Domain(const QString &dataName)
|
Domain::Domain(const QString &dataName)
|
||||||
: _dataName(dataName)
|
: _dataName(dataName)
|
||||||
, _local(std::make_unique<Storage::Domain>(this, dataName)) {
|
, _local(std::make_unique<Storage::Domain>(this, dataName)) {
|
||||||
|
_active.changes(
|
||||||
|
) | rpl::take(1) | rpl::start_with_next([] {
|
||||||
|
Local::rewriteSettingsIfNeeded();
|
||||||
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
Domain::~Domain() = default;
|
Domain::~Domain() = default;
|
||||||
|
@ -39,7 +43,7 @@ Storage::StartResult Domain::start(const QByteArray &passcode) {
|
||||||
const auto result = _local->start(passcode);
|
const auto result = _local->start(passcode);
|
||||||
if (result == Storage::StartResult::Success) {
|
if (result == Storage::StartResult::Success) {
|
||||||
activateAfterStarting();
|
activateAfterStarting();
|
||||||
Local::rewriteSettingsIfNeeded();
|
crl::on_main(&Core::App(), [=] { suggestExportIfNeeded(); });
|
||||||
} else {
|
} else {
|
||||||
Assert(!started());
|
Assert(!started());
|
||||||
}
|
}
|
||||||
|
@ -52,6 +56,19 @@ void Domain::finish() {
|
||||||
base::take(_accounts);
|
base::take(_accounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Domain::suggestExportIfNeeded() {
|
||||||
|
Expects(started());
|
||||||
|
|
||||||
|
for (const auto &[index, account] : _accounts) {
|
||||||
|
if (const auto session = account->maybeSession()) {
|
||||||
|
const auto settings = session->local().readExportSettings();
|
||||||
|
if (const auto availableAt = settings.availableAt) {
|
||||||
|
session->data().suggestStartExport(availableAt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Domain::accountAddedInStorage(AccountWithIndex accountWithIndex) {
|
void Domain::accountAddedInStorage(AccountWithIndex accountWithIndex) {
|
||||||
Expects(accountWithIndex.account != nullptr);
|
Expects(accountWithIndex.account != nullptr);
|
||||||
|
|
||||||
|
@ -95,15 +112,6 @@ void Domain::activateAfterStarting() {
|
||||||
|
|
||||||
activate(toActivate);
|
activate(toActivate);
|
||||||
removePasscodeIfEmpty();
|
removePasscodeIfEmpty();
|
||||||
|
|
||||||
for (const auto &[index, account] : _accounts) {
|
|
||||||
if (const auto session = account->maybeSession()) {
|
|
||||||
const auto settings = session->local().readExportSettings();
|
|
||||||
if (const auto availableAt = settings.availableAt) {
|
|
||||||
session->data().suggestStartExport(availableAt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<Domain::AccountWithIndex> &Domain::accounts() const {
|
const std::vector<Domain::AccountWithIndex> &Domain::accounts() const {
|
||||||
|
|
|
@ -80,6 +80,7 @@ private:
|
||||||
void checkForLastProductionConfig(not_null<Main::Account*> account);
|
void checkForLastProductionConfig(not_null<Main::Account*> account);
|
||||||
void updateUnreadBadge();
|
void updateUnreadBadge();
|
||||||
void scheduleUpdateUnreadBadge();
|
void scheduleUpdateUnreadBadge();
|
||||||
|
void suggestExportIfNeeded();
|
||||||
|
|
||||||
const QString _dataName;
|
const QString _dataName;
|
||||||
const std::unique_ptr<Storage::Domain> _local;
|
const std::unique_ptr<Storage::Domain> _local;
|
||||||
|
|
|
@ -595,6 +595,8 @@ QString readAutoupdatePrefix() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeBackground(const Data::WallPaper &paper, const QImage &image) {
|
void writeBackground(const Data::WallPaper &paper, const QImage &image) {
|
||||||
|
Expects(_settingsWriteAllowed);
|
||||||
|
|
||||||
if (!_backgroundCanWrite) {
|
if (!_backgroundCanWrite) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,7 @@ void Domain::startWithSingleAccount(
|
||||||
if (auto localKey = account->local().peekLegacyLocalKey()) {
|
if (auto localKey = account->local().peekLegacyLocalKey()) {
|
||||||
_localKey = std::move(localKey);
|
_localKey = std::move(localKey);
|
||||||
encryptLocalKey(passcode);
|
encryptLocalKey(passcode);
|
||||||
|
account->start(nullptr);
|
||||||
} else {
|
} else {
|
||||||
generateLocalKey();
|
generateLocalKey();
|
||||||
account->start(account->prepareToStart(_localKey));
|
account->start(account->prepareToStart(_localKey));
|
||||||
|
|
Loading…
Add table
Reference in a new issue