summary refs log tree commit diff
path: root/src/ui
diff options
context:
space:
mode:
authorThulinma <jaron@vietors.com>2021-10-17 17:25:16 +0200
committerThulinma <jaron@vietors.com>2021-10-20 18:31:57 +0200
commit662cb573e1b8bf03733540c5bc1e9dd46824ff99 (patch)
tree03c2fc0c707f75c5215f13ae3f62cdd19ec9a007 /src/ui
parentspeed up blurhash decode a bit (diff)
downloadnheko-662cb573e1b8bf03733540c5bc1e9dd46824ff99.tar.xz
Allow changing device names, display last seen time and IP
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/UserProfile.cpp19
-rw-r--r--src/ui/UserProfile.h5
2 files changed, 23 insertions, 1 deletions
diff --git a/src/ui/UserProfile.cpp b/src/ui/UserProfile.cpp
index 0e3fd39f..b5a16f43 100644
--- a/src/ui/UserProfile.cpp
+++ b/src/ui/UserProfile.cpp
@@ -62,6 +62,8 @@ DeviceInfoModel::roleNames() const
       {DeviceId, "deviceId"},
       {DeviceName, "deviceName"},
       {VerificationStatus, "verificationStatus"},
+      {LastIp, "lastIp"},
+      {LastTs, "lastTs"},
     };
 }
 
@@ -78,6 +80,10 @@ DeviceInfoModel::data(const QModelIndex &index, int role) const
         return deviceList_[index.row()].display_name;
     case VerificationStatus:
         return QVariant::fromValue(deviceList_[index.row()].verification_status);
+    case LastIp:
+        return deviceList_[index.row()].lastIp;
+    case LastTs:
+        return deviceList_[index.row()].lastTs;
     default:
         return {};
     }
@@ -335,6 +341,19 @@ UserProfile::changeUsername(QString username)
 }
 
 void
+UserProfile::changeDeviceName(QString deviceID, QString deviceName)
+{
+    http::client()->set_device_name(
+      deviceID.toStdString(), deviceName.toStdString(), [this](mtx::http::RequestErr err) {
+          if (err) {
+              nhlog::net()->warn("could not change device name");
+              return;
+          }
+          refreshDevices();
+      });
+}
+
+void
 UserProfile::verify(QString device)
 {
     if (!device.isEmpty())
diff --git a/src/ui/UserProfile.h b/src/ui/UserProfile.h
index e8bff6ba..cd2f4740 100644
--- a/src/ui/UserProfile.h
+++ b/src/ui/UserProfile.h
@@ -62,7 +62,7 @@ public:
 
     verification::Status verification_status;
     QString lastIp;
-    size_t lastTs;
+    qlonglong lastTs;
 };
 
 class DeviceInfoModel : public QAbstractListModel
@@ -74,6 +74,8 @@ public:
         DeviceId,
         DeviceName,
         VerificationStatus,
+        LastIp,
+        LastTs,
     };
 
     explicit DeviceInfoModel(QObject *parent = nullptr)
@@ -141,6 +143,7 @@ public:
     Q_INVOKABLE void kickUser();
     Q_INVOKABLE void startChat();
     Q_INVOKABLE void changeUsername(QString username);
+    Q_INVOKABLE void changeDeviceName(QString deviceID, QString deviceName);
     Q_INVOKABLE void changeAvatar();
     Q_INVOKABLE void openGlobalProfile();