|
|
@ -26,11 +26,8 @@ NhekoDBusBackend::getRooms(const QDBusMessage &message) |
|
|
|
new QVector<nheko::dbus::RoomInfoItem>}; |
|
|
|
new QVector<nheko::dbus::RoomInfoItem>}; |
|
|
|
|
|
|
|
|
|
|
|
for (const auto &room : roomListModel) { |
|
|
|
for (const auto &room : roomListModel) { |
|
|
|
MainWindow::instance()->imageProvider()->download( |
|
|
|
auto addRoom = |
|
|
|
room->roomAvatarUrl().remove("mxc://"), |
|
|
|
[room, roomListModelSize = roomListModel.size(), message, model](const QImage &image) { |
|
|
|
{96, 96}, |
|
|
|
|
|
|
|
[message, room, model, roomListModel]( |
|
|
|
|
|
|
|
const QString &, const QSize &, const QImage &image, const QString &) { |
|
|
|
|
|
|
|
const auto aliases = cache::client()->getRoomAliases(room->roomId().toStdString()); |
|
|
|
const auto aliases = cache::client()->getRoomAliases(room->roomId().toStdString()); |
|
|
|
QString alias; |
|
|
|
QString alias; |
|
|
|
if (aliases.has_value()) { |
|
|
|
if (aliases.has_value()) { |
|
|
@ -44,13 +41,24 @@ NhekoDBusBackend::getRooms(const QDBusMessage &message) |
|
|
|
model->push_back(nheko::dbus::RoomInfoItem{ |
|
|
|
model->push_back(nheko::dbus::RoomInfoItem{ |
|
|
|
room->roomId(), room->roomName(), alias, image, room->notificationCount()}); |
|
|
|
room->roomId(), room->roomName(), alias, image, room->notificationCount()}); |
|
|
|
|
|
|
|
|
|
|
|
if (model->length() == roomListModel.size()) { |
|
|
|
if (model->length() == roomListModelSize) { |
|
|
|
auto reply = message.createReply(); |
|
|
|
auto reply = message.createReply(); |
|
|
|
nhlog::ui()->debug("Sending {} rooms over D-Bus...", model->size()); |
|
|
|
nhlog::ui()->debug("Sending {} rooms over D-Bus...", model->size()); |
|
|
|
reply << QVariant::fromValue(*model); |
|
|
|
reply << QVariant::fromValue(*model); |
|
|
|
QDBusConnection::sessionBus().send(reply); |
|
|
|
QDBusConnection::sessionBus().send(reply); |
|
|
|
nhlog::ui()->debug("Rooms successfully sent to D-Bus."); |
|
|
|
nhlog::ui()->debug("Rooms successfully sent to D-Bus."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
true); |
|
|
|
} |
|
|
|
} |
|
|
|