From 456a41bcdf9c0bff99a20bb77d1039c89f2101eb Mon Sep 17 00:00:00 2001 From: Thulinma Date: Sun, 19 Sep 2021 22:55:12 +0200 Subject: Added support for refreshing the device list, marking current device with a checkmark instead of a lock --- src/Cache.cpp | 10 ++++++++++ src/Cache_p.h | 1 + src/ui/UserProfile.cpp | 12 ++++++++++++ src/ui/UserProfile.h | 2 ++ 4 files changed, 25 insertions(+) (limited to 'src') diff --git a/src/Cache.cpp b/src/Cache.cpp index b124fe5e..ee0ca0c2 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -4045,6 +4045,16 @@ Cache::updateUserKeys(const std::string &sync_token, const mtx::responses::Query } } +void +Cache::markUserKeysOutOfDate(const std::vector &user_ids) +{ + auto currentBatchToken = nextBatchToken(); + auto txn = lmdb::txn::begin(env_); + auto db = getUserKeysDb(txn); + markUserKeysOutOfDate(txn, db, user_ids, currentBatchToken); + txn.commit(); +} + void Cache::markUserKeysOutOfDate(lmdb::txn &txn, lmdb::dbi &db, diff --git a/src/Cache_p.h b/src/Cache_p.h index a15010e6..52375d38 100644 --- a/src/Cache_p.h +++ b/src/Cache_p.h @@ -50,6 +50,7 @@ public: const std::string &room_id, bool verified_only); void updateUserKeys(const std::string &sync_token, const mtx::responses::QueryKeys &keyQuery); + void markUserKeysOutOfDate(const std::vector &user_ids); void markUserKeysOutOfDate(lmdb::txn &txn, lmdb::dbi &db, const std::vector &user_ids, diff --git a/src/ui/UserProfile.cpp b/src/ui/UserProfile.cpp index 58150ed7..62488954 100644 --- a/src/ui/UserProfile.cpp +++ b/src/ui/UserProfile.cpp @@ -151,6 +151,15 @@ UserProfile::isSelf() const return this->userid_ == utils::localUser(); } +void +UserProfile::refreshDevices() +{ + std::vector keysToRequest; + keysToRequest.push_back(this->userid_.toStdString()); + cache::client()->markUserKeysOutOfDate(keysToRequest); + fetchDeviceList(this->userid_); +} + void UserProfile::fetchDeviceList(const QString &userID) { @@ -205,6 +214,9 @@ UserProfile::fetchDeviceList(const QString &userID) device, DeviceId(device.device_id), UserId(other_user_id))) verified = verification::Status::VERIFIED; + if (isSelf() && device.device_id == ::http::client()->device_id()) + verified = verification::Status::SELF; + deviceInfo.push_back( {QString::fromStdString(d.first), QString::fromStdString(device.unsigned_info.device_display_name), diff --git a/src/ui/UserProfile.h b/src/ui/UserProfile.h index a148c431..c83ec01e 100644 --- a/src/ui/UserProfile.h +++ b/src/ui/UserProfile.h @@ -18,6 +18,7 @@ Q_NAMESPACE enum Status { + SELF, VERIFIED, UNVERIFIED, BLOCKED @@ -118,6 +119,7 @@ public: Q_INVOKABLE void verify(QString device = ""); Q_INVOKABLE void unverify(QString device = ""); Q_INVOKABLE void fetchDeviceList(const QString &userID); + Q_INVOKABLE void refreshDevices(); Q_INVOKABLE void banUser(); // Q_INVOKABLE void ignoreUser(); Q_INVOKABLE void kickUser(); -- cgit 1.5.1