summary refs log tree commit diff
path: root/src/dbus
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@ymail.com>2022-04-14 17:33:28 +0200
committerNicolas Werner <nicolas.werner@ymail.com>2022-04-14 17:33:28 +0200
commitc3efab43fb93c4deb651c4a0452496b9e573dceb (patch)
tree530407be2cd30108061897911e8f7d21b94bd39d /src/dbus
parentAdd D-Bus API (#916) (diff)
downloadnheko-c3efab43fb93c4deb651c4a0452496b9e573dceb.tar.xz
Cleanup some random dbus stuff
Diffstat (limited to 'src/dbus')
-rw-r--r--src/dbus/NhekoDBusApi.h2
-rw-r--r--src/dbus/NhekoDBusBackend.cpp24
2 files changed, 17 insertions, 9 deletions
diff --git a/src/dbus/NhekoDBusApi.h b/src/dbus/NhekoDBusApi.h
index 47cc108a..d2754f24 100644
--- a/src/dbus/NhekoDBusApi.h
+++ b/src/dbus/NhekoDBusApi.h
@@ -75,6 +75,6 @@ operator<<(QDBusArgument &arg, const QVersionNumber &v);
 const QDBusArgument &
 operator>>(const QDBusArgument &arg, QVersionNumber &v);
 
-#define NHEKO_DBUS_SERVICE_NAME "io.github.Nheko-Reborn.nheko"
+#define NHEKO_DBUS_SERVICE_NAME "im.nheko.Nheko"
 
 #endif // NHEKODBUSAPI_H
diff --git a/src/dbus/NhekoDBusBackend.cpp b/src/dbus/NhekoDBusBackend.cpp
index 3645aea6..7c1c77f8 100644
--- a/src/dbus/NhekoDBusBackend.cpp
+++ b/src/dbus/NhekoDBusBackend.cpp
@@ -26,11 +26,8 @@ NhekoDBusBackend::getRooms(const QDBusMessage &message)
       new QVector<nheko::dbus::RoomInfoItem>};
 
     for (const auto &room : roomListModel) {
-        MainWindow::instance()->imageProvider()->download(
-          room->roomAvatarUrl().remove("mxc://"),
-          {96, 96},
-          [message, room, model, roomListModel](
-            const QString &, const QSize &, const QImage &image, const QString &) {
+        auto addRoom =
+          [room, roomListModelSize = roomListModel.size(), message, model](const QImage &image) {
               const auto aliases = cache::client()->getRoomAliases(room->roomId().toStdString());
               QString alias;
               if (aliases.has_value()) {
@@ -44,15 +41,26 @@ NhekoDBusBackend::getRooms(const QDBusMessage &message)
               model->push_back(nheko::dbus::RoomInfoItem{
                 room->roomId(), room->roomName(), alias, image, room->notificationCount()});
 
-              if (model->length() == roomListModel.size()) {
+              if (model->length() == roomListModelSize) {
                   auto reply = message.createReply();
                   nhlog::ui()->debug("Sending {} rooms over D-Bus...", model->size());
                   reply << QVariant::fromValue(*model);
                   QDBusConnection::sessionBus().send(reply);
                   nhlog::ui()->debug("Rooms successfully sent to D-Bus.");
               }
-          },
-          true);
+          };
+
+        auto avatarUrl = room->roomAvatarUrl();
+        if (avatarUrl.isEmpty())
+            addRoom(QImage());
+        else
+            MainWindow::instance()->imageProvider()->download(
+              avatarUrl.remove("mxc://"),
+              {96, 96},
+              [addRoom](const QString &, const QSize &, const QImage &image, const QString &) {
+                  addRoom(image);
+              },
+              true);
     }
 
     return {};