mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix local storage clearing on logout.
This commit is contained in:
parent
76593b0f3d
commit
c8efb77520
5 changed files with 23 additions and 9 deletions
|
@ -1063,9 +1063,7 @@ void Session::setupUserIsContactViewer() {
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
Session::~Session() {
|
Session::~Session() = default;
|
||||||
clearLocalStorage();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Method>
|
template <typename Method>
|
||||||
void Session::enumerateItemViews(
|
void Session::enumerateItemViews(
|
||||||
|
@ -3786,8 +3784,6 @@ int32 Session::wallpapersHash() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::clearLocalStorage() {
|
void Session::clearLocalStorage() {
|
||||||
clear();
|
|
||||||
|
|
||||||
_cache->close();
|
_cache->close();
|
||||||
_cache->clear();
|
_cache->clear();
|
||||||
_bigFileCache->close();
|
_bigFileCache->close();
|
||||||
|
|
|
@ -57,7 +57,7 @@ Account::~Account() {
|
||||||
if (const auto session = maybeSession()) {
|
if (const auto session = maybeSession()) {
|
||||||
session->saveSettingsNowIfNeeded();
|
session->saveSettingsNowIfNeeded();
|
||||||
}
|
}
|
||||||
destroySession();
|
destroySession(DestroyReason::Quitting);
|
||||||
}
|
}
|
||||||
|
|
||||||
Storage::Domain &Account::domainLocal() const {
|
Storage::Domain &Account::domainLocal() const {
|
||||||
|
@ -188,7 +188,7 @@ void Account::createSession(
|
||||||
Ensures(_session != nullptr);
|
Ensures(_session != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Account::destroySession() {
|
void Account::destroySession(DestroyReason reason) {
|
||||||
_storedSessionSettings.reset();
|
_storedSessionSettings.reset();
|
||||||
_sessionUserId = 0;
|
_sessionUserId = 0;
|
||||||
_sessionUserSerialized = {};
|
_sessionUserSerialized = {};
|
||||||
|
@ -197,6 +197,10 @@ void Account::destroySession() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_sessionValue = nullptr;
|
_sessionValue = nullptr;
|
||||||
|
|
||||||
|
if (reason == DestroyReason::LoggedOut) {
|
||||||
|
_session->finishLogout();
|
||||||
|
}
|
||||||
_session = nullptr;
|
_session = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +511,7 @@ void Account::forcedLogOut() {
|
||||||
void Account::loggedOut() {
|
void Account::loggedOut() {
|
||||||
_loggingOut = false;
|
_loggingOut = false;
|
||||||
Media::Player::mixer()->stopAndClear();
|
Media::Player::mixer()->stopAndClear();
|
||||||
destroySession();
|
destroySession(DestroyReason::LoggedOut);
|
||||||
local().reset();
|
local().reset();
|
||||||
cSetOtherOnline(0);
|
cSetOtherOnline(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ public:
|
||||||
QByteArray serialized,
|
QByteArray serialized,
|
||||||
int streamVersion,
|
int streamVersion,
|
||||||
std::unique_ptr<SessionSettings> settings);
|
std::unique_ptr<SessionSettings> settings);
|
||||||
void destroySession();
|
|
||||||
|
|
||||||
void logOut();
|
void logOut();
|
||||||
void forcedLogOut();
|
void forcedLogOut();
|
||||||
|
@ -107,6 +106,10 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr auto kDefaultSaveDelay = crl::time(1000);
|
static constexpr auto kDefaultSaveDelay = crl::time(1000);
|
||||||
|
enum class DestroyReason {
|
||||||
|
Quitting,
|
||||||
|
LoggedOut,
|
||||||
|
};
|
||||||
|
|
||||||
void startMtp(std::unique_ptr<MTP::Config> config);
|
void startMtp(std::unique_ptr<MTP::Config> config);
|
||||||
void createSession(
|
void createSession(
|
||||||
|
@ -123,6 +126,7 @@ private:
|
||||||
void resetAuthorizationKeys();
|
void resetAuthorizationKeys();
|
||||||
|
|
||||||
void loggedOut();
|
void loggedOut();
|
||||||
|
void destroySession(DestroyReason reason);
|
||||||
|
|
||||||
const not_null<Domain*> _domain;
|
const not_null<Domain*> _domain;
|
||||||
const std::unique_ptr<Storage::Account> _local;
|
const std::unique_ptr<Storage::Account> _local;
|
||||||
|
|
|
@ -151,6 +151,13 @@ Session::Session(
|
||||||
_api->requestNotifySettings(MTP_inputNotifyBroadcasts());
|
_api->requestNotifySettings(MTP_inputNotifyBroadcasts());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Can be called only right before ~Session.
|
||||||
|
void Session::finishLogout() {
|
||||||
|
unlockTerms();
|
||||||
|
data().clear();
|
||||||
|
data().clearLocalStorage();
|
||||||
|
}
|
||||||
|
|
||||||
Session::~Session() {
|
Session::~Session() {
|
||||||
unlockTerms();
|
unlockTerms();
|
||||||
data().clear();
|
data().clear();
|
||||||
|
|
|
@ -140,6 +140,9 @@ public:
|
||||||
[[nodiscard]] QString createInternalLink(const QString &query) const;
|
[[nodiscard]] QString createInternalLink(const QString &query) const;
|
||||||
[[nodiscard]] QString createInternalLinkFull(const QString &query) const;
|
[[nodiscard]] QString createInternalLinkFull(const QString &query) const;
|
||||||
|
|
||||||
|
// Can be called only right before ~Session.
|
||||||
|
void finishLogout();
|
||||||
|
|
||||||
[[nodiscard]] rpl::lifetime &lifetime() {
|
[[nodiscard]] rpl::lifetime &lifetime() {
|
||||||
return _lifetime;
|
return _lifetime;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue