|
|
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:collection/collection.dart';
|
|
|
|
|
import 'package:desktop_notifications/desktop_notifications.dart';
|
|
|
|
|
import 'package:image/image.dart';
|
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
|
import 'package:universal_html/html.dart' as html;
|
|
|
|
|
|
|
|
|
@ -13,6 +14,7 @@ import 'package:fluffychat/l10n/l10n.dart';
|
|
|
|
|
import 'package:fluffychat/utils/client_download_content_extension.dart';
|
|
|
|
|
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
|
|
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
|
|
|
|
import 'package:fluffychat/utils/push_helper.dart';
|
|
|
|
|
import 'package:fluffychat/widgets/fluffy_chat_app.dart';
|
|
|
|
|
import 'package:fluffychat/widgets/matrix.dart';
|
|
|
|
|
|
|
|
|
@ -77,6 +79,35 @@ extension LocalNotificationsExtension on MatrixState {
|
|
|
|
|
tag: event.room.id,
|
|
|
|
|
);
|
|
|
|
|
} else if (Platform.isLinux) {
|
|
|
|
|
final avatarUrl = event.room.avatar;
|
|
|
|
|
final hints = [NotificationHint.soundName('message-new-instant')];
|
|
|
|
|
|
|
|
|
|
if (avatarUrl != null) {
|
|
|
|
|
const size = notificationAvatarDimension;
|
|
|
|
|
const thumbnailMethod = ThumbnailMethod.crop;
|
|
|
|
|
// Pre-cache so that we can later just set the thumbnail uri as icon:
|
|
|
|
|
final data = await client.downloadMxcCached(
|
|
|
|
|
avatarUrl,
|
|
|
|
|
width: size,
|
|
|
|
|
height: size,
|
|
|
|
|
thumbnailMethod: thumbnailMethod,
|
|
|
|
|
isThumbnail: true,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final image = decodeImage(data);
|
|
|
|
|
if (image != null) {
|
|
|
|
|
final realData = image.getBytes(order: ChannelOrder.rgba);
|
|
|
|
|
hints.add(
|
|
|
|
|
NotificationHint.imageData(
|
|
|
|
|
image.width,
|
|
|
|
|
image.height,
|
|
|
|
|
realData,
|
|
|
|
|
hasAlpha: true,
|
|
|
|
|
channels: 4,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
final notification = await linuxNotifications!.notify(
|
|
|
|
|
title,
|
|
|
|
|
body: body,
|
|
|
|
@ -93,9 +124,7 @@ extension LocalNotificationsExtension on MatrixState {
|
|
|
|
|
L10n.of(context).markAsRead,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
hints: [
|
|
|
|
|
NotificationHint.soundName('message-new-instant'),
|
|
|
|
|
],
|
|
|
|
|
hints: hints,
|
|
|
|
|
);
|
|
|
|
|
notification.action.then((actionStr) {
|
|
|
|
|
var action = DesktopNotificationActions.values
|
|
|
|
|