From 020a842aefe6c602428fa8e85e3f5bfa1239b666 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sun, 14 Jan 2018 23:33:12 +0200 Subject: Change cache format to not allow duplicate receipts Convert list of receipts to map --- include/Cache.h | 22 +--------------------- include/dialogs/ReadReceipts.h | 2 +- 2 files changed, 2 insertions(+), 22 deletions(-) (limited to 'include') diff --git a/include/Cache.h b/include/Cache.h index 761c6060..7a626e12 100644 --- a/include/Cache.h +++ b/include/Cache.h @@ -44,26 +44,6 @@ from_json(const json &j, ReadReceiptKey &key) key.room_id = j.at("room_id").get(); } -//! Decribes a read receipt stored in cache. -struct ReadReceiptValue -{ - std::string user_id; - uint64_t ts; -}; - -inline void -to_json(json &j, const ReadReceiptValue &value) -{ - j = json{{"user_id", value.user_id}, {"ts", value.ts}}; -} - -inline void -from_json(const json &j, ReadReceiptValue &value) -{ - value.user_id = j.at("user_id").get(); - value.ts = j.at("ts").get(); -} - class Cache { public: @@ -100,7 +80,7 @@ public: //! Retrieve all the read receipts for the given event id and room. //! //! Returns a map of user ids and the time of the read receipt in milliseconds. - using UserReceipts = std::multimap; + using UserReceipts = std::multimap>; UserReceipts readReceipts(const QString &event_id, const QString &room_id); QByteArray image(const QString &url) const; diff --git a/include/dialogs/ReadReceipts.h b/include/dialogs/ReadReceipts.h index 42a9e1b7..8f860b46 100644 --- a/include/dialogs/ReadReceipts.h +++ b/include/dialogs/ReadReceipts.h @@ -37,7 +37,7 @@ public: explicit ReadReceipts(QWidget *parent = nullptr); public slots: - void addUsers(const std::multimap &users); + void addUsers(const std::multimap> &users); protected: void paintEvent(QPaintEvent *event) override; -- cgit 1.5.1