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