mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Fix app start without data.
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user