|
|
@ -26,29 +26,30 @@ NhekoDBusBackend::rooms(const QDBusMessage &message) |
|
|
|
new QVector<nheko::dbus::RoomInfoItem>}; |
|
|
|
new QVector<nheko::dbus::RoomInfoItem>}; |
|
|
|
|
|
|
|
|
|
|
|
for (const auto &room : roomListModel) { |
|
|
|
for (const auto &room : roomListModel) { |
|
|
|
auto addRoom = |
|
|
|
auto addRoom = [room, roomListModelSize = roomListModel.size(), message, model]( |
|
|
|
[room, roomListModelSize = roomListModel.size(), message, model](const QImage &image) { |
|
|
|
const QImage &image) { |
|
|
|
const auto aliases = cache::client()->getRoomAliases(room->roomId().toStdString()); |
|
|
|
const auto aliases = cache::client()->getStateEvent<mtx::events::state::CanonicalAlias>( |
|
|
|
QString alias; |
|
|
|
room->roomId().toStdString()); |
|
|
|
if (aliases.has_value()) { |
|
|
|
QString alias; |
|
|
|
const auto &val = aliases.value(); |
|
|
|
if (aliases.has_value()) { |
|
|
|
if (!val.alias.empty()) |
|
|
|
const auto &val = aliases.value().content; |
|
|
|
alias = QString::fromStdString(val.alias); |
|
|
|
if (!val.alias.empty()) |
|
|
|
else if (val.alt_aliases.size() > 0) |
|
|
|
alias = QString::fromStdString(val.alias); |
|
|
|
alias = QString::fromStdString(val.alt_aliases.front()); |
|
|
|
else if (val.alt_aliases.size() > 0) |
|
|
|
} |
|
|
|
alias = QString::fromStdString(val.alt_aliases.front()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
model->push_back(nheko::dbus::RoomInfoItem{ |
|
|
|
model->push_back(nheko::dbus::RoomInfoItem{ |
|
|
|
room->roomId(), alias, room->roomName(), image, room->notificationCount()}); |
|
|
|
room->roomId(), alias, room->roomName(), image, room->notificationCount()}); |
|
|
|
|
|
|
|
|
|
|
|
if (model->length() == roomListModelSize) { |
|
|
|
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(); |
|
|
|
auto avatarUrl = room->roomAvatarUrl(); |
|
|
|
if (avatarUrl.isEmpty()) |
|
|
|
if (avatarUrl.isEmpty()) |
|
|
|