mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +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) {
|
||||
Expects(!_appConfig);
|
||||
|
||||
const auto result = _local->legacyStart(passcode);
|
||||
if (result == Storage::StartResult::Success) {
|
||||
start(nullptr);
|
||||
}
|
||||
return result;
|
||||
return _local->legacyStart(passcode);
|
||||
}
|
||||
|
||||
std::unique_ptr<MTP::Config> Account::prepareToStart(
|
||||
|
|
|
@ -25,6 +25,10 @@ namespace Main {
|
|||
Domain::Domain(const QString &dataName)
|
||||
: _dataName(dataName)
|
||||
, _local(std::make_unique<Storage::Domain>(this, dataName)) {
|
||||
_active.changes(
|
||||
) | rpl::take(1) | rpl::start_with_next([] {
|
||||
Local::rewriteSettingsIfNeeded();
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
Domain::~Domain() = default;
|
||||
|
@ -39,7 +43,7 @@ Storage::StartResult Domain::start(const QByteArray &passcode) {
|
|||
const auto result = _local->start(passcode);
|
||||
if (result == Storage::StartResult::Success) {
|
||||
activateAfterStarting();
|
||||
Local::rewriteSettingsIfNeeded();
|
||||
crl::on_main(&Core::App(), [=] { suggestExportIfNeeded(); });
|
||||
} else {
|
||||
Assert(!started());
|
||||
}
|
||||
|
@ -52,6 +56,19 @@ void Domain::finish() {
|
|||
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) {
|
||||
Expects(accountWithIndex.account != nullptr);
|
||||
|
||||
|
@ -95,15 +112,6 @@ void Domain::activateAfterStarting() {
|
|||
|
||||
activate(toActivate);
|
||||
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 {
|
||||
|
|
|
@ -80,6 +80,7 @@ private:
|
|||
void checkForLastProductionConfig(not_null<Main::Account*> account);
|
||||
void updateUnreadBadge();
|
||||
void scheduleUpdateUnreadBadge();
|
||||
void suggestExportIfNeeded();
|
||||
|
||||
const QString _dataName;
|
||||
const std::unique_ptr<Storage::Domain> _local;
|
||||
|
|
|
@ -595,6 +595,8 @@ QString readAutoupdatePrefix() {
|
|||
}
|
||||
|
||||
void writeBackground(const Data::WallPaper &paper, const QImage &image) {
|
||||
Expects(_settingsWriteAllowed);
|
||||
|
||||
if (!_backgroundCanWrite) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ void Domain::startWithSingleAccount(
|
|||
if (auto localKey = account->local().peekLegacyLocalKey()) {
|
||||
_localKey = std::move(localKey);
|
||||
encryptLocalKey(passcode);
|
||||
account->start(nullptr);
|
||||
} else {
|
||||
generateLocalKey();
|
||||
account->start(account->prepareToStart(_localKey));
|
||||
|
|
Loading…
Add table
Reference in a new issue