mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 12:25:11 +00:00
refactor: Preload notification sound on web
This commit is contained in:
parent
3ad872dfa3
commit
f3798f3ee8
1 changed files with 5 additions and 4 deletions
|
@ -17,6 +17,10 @@ import 'package:fluffychat/utils/platform_infos.dart';
|
||||||
import 'package:fluffychat/widgets/matrix.dart';
|
import 'package:fluffychat/widgets/matrix.dart';
|
||||||
|
|
||||||
extension LocalNotificationsExtension on MatrixState {
|
extension LocalNotificationsExtension on MatrixState {
|
||||||
|
static final html.AudioElement _audioPlayer = html.AudioElement()
|
||||||
|
..src = 'assets/assets/sounds/notification.ogg'
|
||||||
|
..load();
|
||||||
|
|
||||||
void showLocalNotification(EventUpdate eventUpdate) async {
|
void showLocalNotification(EventUpdate eventUpdate) async {
|
||||||
final roomId = eventUpdate.roomID;
|
final roomId = eventUpdate.roomID;
|
||||||
if (activeRoomId == roomId) {
|
if (activeRoomId == roomId) {
|
||||||
|
@ -56,10 +60,7 @@ extension LocalNotificationsExtension on MatrixState {
|
||||||
method: ThumbnailMethod.crop,
|
method: ThumbnailMethod.crop,
|
||||||
);
|
);
|
||||||
if (kIsWeb) {
|
if (kIsWeb) {
|
||||||
html.AudioElement()
|
_audioPlayer.play();
|
||||||
..src = 'assets/assets/sounds/notification.ogg'
|
|
||||||
..autoplay = true
|
|
||||||
..load();
|
|
||||||
html.Notification(
|
html.Notification(
|
||||||
title,
|
title,
|
||||||
body: body,
|
body: body,
|
||||||
|
|
Loading…
Reference in a new issue