Merge pull request #2780 from krille-chan/krille/bring-back-notification-sound
refactor: Bring back notification web sound but make configurable
This commit is contained in:
commit
0e77ce53ec
4 changed files with 18 additions and 2 deletions
|
|
@ -68,7 +68,8 @@ enum AppSettings<T> {
|
|||
tos<String>('chat.fluffy.tos_url', 'https://fluffychat.im/en/tos'),
|
||||
sendTimelineEventTimeout<int>('chat.fluffy.send_timeline_event_timeout', 15),
|
||||
lastSeenSupportBanner<int>('chat.fluffy.last_seen_support_banner', 0),
|
||||
supportBannerOptOut<bool>('chat.fluffy.support_banner_opt_out', false);
|
||||
supportBannerOptOut<bool>('chat.fluffy.support_banner_opt_out', false),
|
||||
webNotificationSound<bool>('chat.fluffy.web_notification_sound', true);
|
||||
|
||||
final String key;
|
||||
final T defaultValue;
|
||||
|
|
|
|||
|
|
@ -2797,5 +2797,6 @@
|
|||
"startVideoCall": "Start video call",
|
||||
"joinVoiceCall": "Join voice call",
|
||||
"joinVideoCall": "Join video call",
|
||||
"live": "Live"
|
||||
"live": "Live",
|
||||
"playSoundOnNotification": "Play sound on notification"
|
||||
}
|
||||
|
|
@ -1,7 +1,10 @@
|
|||
import 'package:fluffychat/config/setting_keys.dart';
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pages/settings_notifications/push_rule_extensions.dart';
|
||||
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
|
||||
import 'package:fluffychat/widgets/settings_switch_list_tile.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
|
|
@ -47,6 +50,11 @@ class SettingsNotificationsView extends StatelessWidget {
|
|||
return SelectionArea(
|
||||
child: Column(
|
||||
children: [
|
||||
if (kIsWeb)
|
||||
SettingsSwitchListTile.adaptive(
|
||||
title: L10n.of(context).playSoundOnNotification,
|
||||
setting: AppSettings.webNotificationSound,
|
||||
),
|
||||
if (pushRules != null)
|
||||
for (final category in pushCategories) ...[
|
||||
ListTile(
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@ import 'package:matrix/matrix.dart';
|
|||
import 'package:universal_html/html.dart' as html;
|
||||
|
||||
extension LocalNotificationsExtension on MatrixState {
|
||||
static final html.AudioElement _audioPlayer = html.AudioElement()
|
||||
..src = 'assets/assets/sounds/notification.ogg'
|
||||
..load();
|
||||
|
||||
Future<void> showLocalNotification(Event event) async {
|
||||
final l10n = L10n.of(context);
|
||||
final roomId = event.room.id;
|
||||
|
|
@ -69,6 +73,8 @@ extension LocalNotificationsExtension on MatrixState {
|
|||
);
|
||||
}
|
||||
|
||||
if (AppSettings.webNotificationSound.value) _audioPlayer.play();
|
||||
|
||||
html.Notification(
|
||||
title,
|
||||
body: body,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue