mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Cleanup some random dbus stuff
This commit is contained in:
parent
686ebfdbec
commit
c3efab43fb
2 changed files with 17 additions and 9 deletions
|
@ -75,6 +75,6 @@ operator<<(QDBusArgument &arg, const QVersionNumber &v);
|
||||||
const QDBusArgument &
|
const QDBusArgument &
|
||||||
operator>>(const QDBusArgument &arg, QVersionNumber &v);
|
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
|
#endif // NHEKODBUSAPI_H
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue