mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Remove cache data when the user logs out
This commit is contained in:
parent
7fbfe3af15
commit
177dd6a5b0
3 changed files with 16 additions and 1 deletions
|
@ -17,6 +17,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QDir>
|
||||
#include <lmdb++.h>
|
||||
|
||||
#include "RoomState.h"
|
||||
|
@ -32,6 +33,7 @@ public:
|
|||
QString nextBatchToken() const;
|
||||
QMap<QString, RoomState> states();
|
||||
|
||||
inline void deleteData();
|
||||
inline void unmount();
|
||||
inline QString memberDbName(const QString &roomid);
|
||||
|
||||
|
@ -46,6 +48,7 @@ private:
|
|||
bool isMounted_;
|
||||
|
||||
QString userId_;
|
||||
QString cacheDirectory_;
|
||||
};
|
||||
|
||||
inline void
|
||||
|
@ -59,3 +62,10 @@ Cache::memberDbName(const QString &roomid)
|
|||
{
|
||||
return QString("m.%1").arg(roomid);
|
||||
}
|
||||
|
||||
inline void
|
||||
Cache::deleteData()
|
||||
{
|
||||
if (!cacheDirectory_.isEmpty())
|
||||
QDir(cacheDirectory_).removeRecursively();
|
||||
}
|
||||
|
|
|
@ -83,7 +83,10 @@ Cache::Cache(const QString &userId)
|
|||
|
||||
txn.commit();
|
||||
|
||||
isMounted_ = true;
|
||||
isMounted_ = true;
|
||||
cacheDirectory_ = QString("%1/%2")
|
||||
.arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation))
|
||||
.arg(QString::fromUtf8(userId_.toUtf8().toHex()));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -194,6 +194,8 @@ ChatPage::logout()
|
|||
settings.remove("");
|
||||
settings.endGroup();
|
||||
|
||||
cache_->deleteData();
|
||||
|
||||
// Clear the environment.
|
||||
room_list_->clear();
|
||||
view_manager_->clearAll();
|
||||
|
|
Loading…
Reference in a new issue