mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-23 03:18:49 +03:00
Fix avatars in notifications
This commit is contained in:
parent
fef0cc2d71
commit
8af056faa9
2 changed files with 23 additions and 14 deletions
|
@ -34,10 +34,12 @@ resolve(const QString &avatarUrl, int size, QObject *receiver, AvatarCallback ca
|
||||||
{
|
{
|
||||||
const auto cacheKey = QString("%1_size_%2").arg(avatarUrl).arg(size);
|
const auto cacheKey = QString("%1_size_%2").arg(avatarUrl).arg(size);
|
||||||
|
|
||||||
if (avatarUrl.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
|
if (avatarUrl.isEmpty()) {
|
||||||
|
callback(pixmap);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (avatar_cache.find(cacheKey, &pixmap)) {
|
if (avatar_cache.find(cacheKey, &pixmap)) {
|
||||||
callback(pixmap);
|
callback(pixmap);
|
||||||
return;
|
return;
|
||||||
|
@ -75,10 +77,9 @@ resolve(const QString &avatarUrl, int size, QObject *receiver, AvatarCallback ca
|
||||||
opts.mxc_url,
|
opts.mxc_url,
|
||||||
mtx::errors::to_string(err->matrix_error.errcode),
|
mtx::errors::to_string(err->matrix_error.errcode),
|
||||||
err->matrix_error.error);
|
err->matrix_error.error);
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
cache::saveImage(cacheKey.toStdString(), res);
|
cache::saveImage(cacheKey.toStdString(), res);
|
||||||
|
}
|
||||||
|
|
||||||
emit proxy->avatarDownloaded(QByteArray(res.data(), res.size()));
|
emit proxy->avatarDownloaded(QByteArray(res.data(), res.size()));
|
||||||
});
|
});
|
||||||
|
|
|
@ -895,14 +895,22 @@ ChatPage::sendNotifications(const mtx::responses::Notifications &res)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userSettings_->hasDesktopNotifications()) {
|
if (userSettings_->hasDesktopNotifications()) {
|
||||||
|
auto info = cache::singleRoomInfo(item.room_id);
|
||||||
|
|
||||||
|
AvatarProvider::resolve(
|
||||||
|
QString::fromStdString(info.avatar_url),
|
||||||
|
96,
|
||||||
|
this,
|
||||||
|
[this, room_id, event_id, item, user_id, info](
|
||||||
|
QPixmap image) {
|
||||||
notificationsManager.postNotification(
|
notificationsManager.postNotification(
|
||||||
room_id,
|
room_id,
|
||||||
QString::fromStdString(event_id),
|
QString::fromStdString(event_id),
|
||||||
QString::fromStdString(
|
QString::fromStdString(info.name),
|
||||||
cache::singleRoomInfo(item.room_id).name),
|
|
||||||
cache::displayName(room_id, user_id),
|
cache::displayName(room_id, user_id),
|
||||||
utils::event_body(item.event),
|
utils::event_body(item.event),
|
||||||
cache::getRoomAvatar(room_id));
|
image.toImage());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (const lmdb::error &e) {
|
} catch (const lmdb::error &e) {
|
||||||
|
|
Loading…
Reference in a new issue