chore: Follow up add web notification icons with auth media

This commit is contained in:
Krille 2024-08-29 08:20:46 +02:00
commit e6948ee0b4
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652

View file

@ -50,26 +50,35 @@ extension LocalNotificationsExtension on MatrixState {
if (kIsWeb) { if (kIsWeb) {
final avatarUrl = event.senderFromMemoryOrFallback.avatarUrl; final avatarUrl = event.senderFromMemoryOrFallback.avatarUrl;
Uri? thumbnailUri;
final iconBytes = avatarUrl == null if (avatarUrl != null) {
? null const size = 64;
: await client.downloadMxcCached( const thumbnailMethod = ThumbnailMethod.crop;
avatarUrl, // Pre-cache so that we can later just set the thumbnail uri as icon:
width: 64, await client.downloadMxcCached(
height: 64, avatarUrl,
thumbnailMethod: ThumbnailMethod.crop, width: size,
isThumbnail: true, height: size,
animated: false, thumbnailMethod: thumbnailMethod,
); isThumbnail: true,
);
thumbnailUri =
await event.senderFromMemoryOrFallback.avatarUrl?.getThumbnailUri(
client,
width: size,
height: size,
method: thumbnailMethod,
);
}
_audioPlayer.play(); _audioPlayer.play();
html.Notification( html.Notification(
title, title,
body: body, body: body,
icon: iconBytes == null icon: thumbnailUri?.toString(),
? null
: html.Url.createObjectUrl(html.Blob(iconBytes)),
tag: event.room.id, tag: event.room.id,
); );
} else if (Platform.isLinux) { } else if (Platform.isLinux) {