chore: Follow up notification action
This commit is contained in:
parent
a88849c2db
commit
1bef2dcbbb
2 changed files with 25 additions and 3 deletions
|
|
@ -9,6 +9,7 @@ import 'package:matrix/matrix.dart';
|
|||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/utils/client_download_content_extension.dart';
|
||||
import 'package:fluffychat/utils/client_manager.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
|
|
@ -157,16 +158,37 @@ Future<void> notificationTap(
|
|||
final eventId = await room.sendTextEvent(input);
|
||||
|
||||
if (PlatformInfos.isAndroid) {
|
||||
final ownProfile = await room.client.fetchOwnProfile();
|
||||
final avatar = ownProfile.avatarUrl;
|
||||
final avatarFile = avatar == null
|
||||
? null
|
||||
: await client
|
||||
.downloadMxcCached(
|
||||
avatar,
|
||||
thumbnailMethod: ThumbnailMethod.crop,
|
||||
width: notificationAvatarDimension,
|
||||
height: notificationAvatarDimension,
|
||||
animated: false,
|
||||
isThumbnail: true,
|
||||
rounded: true,
|
||||
)
|
||||
.timeout(const Duration(seconds: 3));
|
||||
final messagingStyleInformation =
|
||||
await AndroidFlutterLocalNotificationsPlugin()
|
||||
.getActiveNotificationMessagingStyle(room.id.hashCode);
|
||||
if (messagingStyleInformation == null) return;
|
||||
l10n ??= await lookupL10n(const Locale('en'));
|
||||
l10n ??= await lookupL10n(PlatformDispatcher.instance.locale);
|
||||
messagingStyleInformation.messages?.add(
|
||||
Message(
|
||||
input,
|
||||
DateTime.now(),
|
||||
Person(key: room.client.userID, name: l10n.you),
|
||||
Person(
|
||||
key: room.client.userID,
|
||||
name: l10n.you,
|
||||
icon: avatarFile == null
|
||||
? null
|
||||
: ByteArrayAndroidIcon(avatarFile),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ Future<void> pushHelper(
|
|||
} catch (e, s) {
|
||||
Logs().e('Push Helper has crashed! Writing into temporary file', e, s);
|
||||
|
||||
l10n ??= await lookupL10n(const Locale('en'));
|
||||
l10n ??= await lookupL10n(PlatformDispatcher.instance.locale);
|
||||
flutterLocalNotificationsPlugin.show(
|
||||
notification.roomId?.hashCode ?? 0,
|
||||
l10n.newMessageInFluffyChat,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue