Implement media cache
2 files changed, 9 insertions, 6 deletions
diff --git a/include/AvatarProvider.h b/include/AvatarProvider.h
index dabd609c..fd5f15c4 100644
--- a/include/AvatarProvider.h
+++ b/include/AvatarProvider.h
@@ -24,23 +24,26 @@
class MatrixClient;
class TimelineItem;
+class Cache;
class AvatarProvider : public QObject
{
Q_OBJECT
public:
- static void init(QSharedPointer<MatrixClient> client) { client_ = client; }
+ static void init(QSharedPointer<MatrixClient> client, QSharedPointer<Cache> cache)
+ {
+ client_ = client;
+ cache_ = cache;
+ }
//! The callback is called with the downloaded avatar for the given user
//! or the avatar is downloaded first and then saved for re-use.
static void resolve(const QString &room_id,
const QString &userId,
QObject *receiver,
std::function<void(QImage)> callback);
- //! Remove all saved data.
- static void clear() { avatars_.clear(); };
private:
static QSharedPointer<MatrixClient> client_;
- static QHash<QString, QImage> avatars_;
+ static QSharedPointer<Cache> cache_;
};
diff --git a/include/ChatPage.h b/include/ChatPage.h
index b3b379cb..d0be9ce1 100644
--- a/include/ChatPage.h
+++ b/include/ChatPage.h
@@ -51,8 +51,8 @@ constexpr int CONSENSUS_TIMEOUT = 1000;
constexpr int SHOW_CONTENT_TIMEOUT = 3000;
constexpr int TYPING_REFRESH_TIMEOUT = 10000;
-Q_DECLARE_METATYPE(mtx::responses::Rooms);
-Q_DECLARE_METATYPE(std::vector<std::string>);
+Q_DECLARE_METATYPE(mtx::responses::Rooms)
+Q_DECLARE_METATYPE(std::vector<std::string>)
class ChatPage : public QWidget
{
|