mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +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
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
#include <lmdb++.h>
|
#include <lmdb++.h>
|
||||||
|
|
||||||
#include "RoomState.h"
|
#include "RoomState.h"
|
||||||
|
@ -32,6 +33,7 @@ public:
|
||||||
QString nextBatchToken() const;
|
QString nextBatchToken() const;
|
||||||
QMap<QString, RoomState> states();
|
QMap<QString, RoomState> states();
|
||||||
|
|
||||||
|
inline void deleteData();
|
||||||
inline void unmount();
|
inline void unmount();
|
||||||
inline QString memberDbName(const QString &roomid);
|
inline QString memberDbName(const QString &roomid);
|
||||||
|
|
||||||
|
@ -46,6 +48,7 @@ private:
|
||||||
bool isMounted_;
|
bool isMounted_;
|
||||||
|
|
||||||
QString userId_;
|
QString userId_;
|
||||||
|
QString cacheDirectory_;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
|
@ -59,3 +62,10 @@ Cache::memberDbName(const QString &roomid)
|
||||||
{
|
{
|
||||||
return QString("m.%1").arg(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();
|
txn.commit();
|
||||||
|
|
||||||
isMounted_ = true;
|
isMounted_ = true;
|
||||||
|
cacheDirectory_ = QString("%1/%2")
|
||||||
|
.arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation))
|
||||||
|
.arg(QString::fromUtf8(userId_.toUtf8().toHex()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -194,6 +194,8 @@ ChatPage::logout()
|
||||||
settings.remove("");
|
settings.remove("");
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
|
cache_->deleteData();
|
||||||
|
|
||||||
// Clear the environment.
|
// Clear the environment.
|
||||||
room_list_->clear();
|
room_list_->clear();
|
||||||
view_manager_->clearAll();
|
view_manager_->clearAll();
|
||||||
|
|
Loading…
Reference in a new issue