mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Added support for refreshing the device list, marking current device with a checkmark instead of a lock
This commit is contained in:
parent
acc257ea06
commit
456a41bcdf
8 changed files with 72 additions and 8 deletions
BIN
resources/icons/ui/refresh.png
Normal file
BIN
resources/icons/ui/refresh.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
16
resources/icons/ui/refresh.svg
Normal file
16
resources/icons/ui/refresh.svg
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
version="1.1"
|
||||
viewBox="-10 0 1792 1792"
|
||||
id="svg866"
|
||||
width="1792"
|
||||
height="1792"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs870" />
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="m 1629,1056 q 0,5 -1,7 -64,268 -268,434.5 Q 1156,1664 882,1664 736,1664 599.5,1609 463,1554 356,1452 l -129,129 q -19,19 -45,19 -26,0 -45,-19 -19,-19 -19,-45 v -448 q 0,-26 19,-45 19,-19 45,-19 h 448 q 26,0 45,19 19,19 19,45 0,26 -19,45 l -137,137 q 71,66 161,102 90,36 187,36 134,0 250,-65 116,-65 186,-179 11,-17 53,-117 8,-23 30,-23 h 192 q 13,0 22.5,9.5 9.5,9.5 9.5,22.5 z m 25,-800 v 448 q 0,26 -19,45 -19,19 -45,19 h -448 q -26,0 -45,-19 -19,-19 -19,-45 0,-26 19,-45 L 1235,521 Q 1087,384 886,384 q -134,0 -250,65 -116,65 -186,179 -11,17 -53,117 -8,23 -30,23 H 168 q -13,0 -22.5,-9.5 Q 136,749 136,736 v -7 Q 201,461 406,294.5 611,128 886,128 q 146,0 284,55.5 138,55.5 245,156.5 l 130,-129 q 19,-19 45,-19 26,0 45,19 19,19 19,45 z"
|
||||
id="path864" />
|
||||
</svg>
|
After Width: | Height: | Size: 1 KiB |
|
@ -249,6 +249,14 @@ ApplicationWindow {
|
|||
visible: !profile.isGlobalUserProfile && profile.room.permissions.canBan()
|
||||
}
|
||||
|
||||
ImageButton {
|
||||
image: ":/icons/icons/ui/refresh.png"
|
||||
hoverEnabled: true
|
||||
ToolTip.visible: hovered
|
||||
ToolTip.text: qsTr("Refresh device list.")
|
||||
onClicked: profile.refreshDevices();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,6 +272,9 @@ ApplicationWindow {
|
|||
|
||||
|
||||
delegate: RowLayout {
|
||||
required property int verificationStatus
|
||||
required property string deviceId
|
||||
required property string deviceName
|
||||
width: devicelist.width
|
||||
spacing: 4
|
||||
|
||||
|
@ -276,7 +287,7 @@ ApplicationWindow {
|
|||
elide: Text.ElideRight
|
||||
font.bold: true
|
||||
color: Nheko.colors.text
|
||||
text: model.deviceId
|
||||
text: deviceId
|
||||
}
|
||||
|
||||
Text {
|
||||
|
@ -284,7 +295,7 @@ ApplicationWindow {
|
|||
Layout.alignment: Qt.AlignRight
|
||||
elide: Text.ElideRight
|
||||
color: Nheko.colors.text
|
||||
text: model.deviceName
|
||||
text: deviceName
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -292,19 +303,30 @@ ApplicationWindow {
|
|||
Image {
|
||||
Layout.preferredHeight: 16
|
||||
Layout.preferredWidth: 16
|
||||
source: ((model.verificationStatus == VerificationStatus.VERIFIED) ? "image://colorimage/:/icons/icons/ui/lock.png?green" : ((model.verificationStatus == VerificationStatus.UNVERIFIED) ? "image://colorimage/:/icons/icons/ui/unlock.png?yellow" : "image://colorimage/:/icons/icons/ui/unlock.png?red"))
|
||||
source: {
|
||||
switch (verificationStatus){
|
||||
case VerificationStatus.VERIFIED:
|
||||
return "image://colorimage/:/icons/icons/ui/lock.png?green";
|
||||
case VerificationStatus.UNVERIFIED:
|
||||
return "image://colorimage/:/icons/icons/ui/unlock.png?yellow";
|
||||
case VerificationStatus.SELF:
|
||||
return "image://colorimage/:/icons/icons/ui/checkmark.png?green";
|
||||
default:
|
||||
return "image://colorimage/:/icons/icons/ui/unlock.png?red";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
id: verifyButton
|
||||
|
||||
visible: (!profile.userVerificationEnabled && !profile.isSelf) || (profile.isSelf && (model.verificationStatus != VerificationStatus.VERIFIED || !profile.userVerificationEnabled))
|
||||
text: (model.verificationStatus != VerificationStatus.VERIFIED) ? qsTr("Verify") : qsTr("Unverify")
|
||||
visible: (!profile.userVerificationEnabled && !profile.isSelf) || (profile.isSelf && (verificationStatus == VerificationStatus.UNVERIFIED || !profile.userVerificationEnabled))
|
||||
text: (verificationStatus != VerificationStatus.VERIFIED) ? qsTr("Verify") : qsTr("Unverify")
|
||||
onClicked: {
|
||||
if (model.verificationStatus == VerificationStatus.VERIFIED)
|
||||
profile.unverify(model.deviceId);
|
||||
if (verificationStatus == VerificationStatus.VERIFIED)
|
||||
profile.unverify(deviceId);
|
||||
else
|
||||
profile.verify(model.deviceId);
|
||||
profile.verify(deviceId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
<file>icons/ui/screen-share.png</file>
|
||||
<file>icons/ui/toggle-camera-view.png</file>
|
||||
<file>icons/ui/video-call.png</file>
|
||||
<file>icons/ui/refresh.png</file>
|
||||
<file>icons/emoji-categories/people.png</file>
|
||||
<file>icons/emoji-categories/people@2x.png</file>
|
||||
<file>icons/emoji-categories/nature.png</file>
|
||||
|
|
|
@ -4045,6 +4045,16 @@ Cache::updateUserKeys(const std::string &sync_token, const mtx::responses::Query
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Cache::markUserKeysOutOfDate(const std::vector<std::string> &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,
|
||||
|
|
|
@ -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<std::string> &user_ids);
|
||||
void markUserKeysOutOfDate(lmdb::txn &txn,
|
||||
lmdb::dbi &db,
|
||||
const std::vector<std::string> &user_ids,
|
||||
|
|
|
@ -151,6 +151,15 @@ UserProfile::isSelf() const
|
|||
return this->userid_ == utils::localUser();
|
||||
}
|
||||
|
||||
void
|
||||
UserProfile::refreshDevices()
|
||||
{
|
||||
std::vector<std::string> 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),
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue