chore: Follow up add web notification icons with auth media
This commit is contained in:
parent
e38ccbebbe
commit
e6948ee0b4
1 changed files with 22 additions and 13 deletions
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue