From 5913d03bd2b122ddf96f1bbe258b916420b797d3 Mon Sep 17 00:00:00 2001 From: Frederik Feichtmeier Date: Mon, 21 Oct 2024 19:09:00 +0200 Subject: [PATCH] fix: only display discord events on connect and only if enabled (#967) --- lib/app/view/scaffold.dart | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/app/view/scaffold.dart b/lib/app/view/scaffold.dart index 3a98657c..3b3ca0ff 100644 --- a/lib/app/view/scaffold.dart +++ b/lib/app/view/scaffold.dart @@ -11,6 +11,7 @@ import '../../extensions/build_context_x.dart'; import '../../l10n/l10n.dart'; import '../../patch_notes/patch_notes_dialog.dart'; import '../../player/view/player_view.dart'; +import '../../settings/settings_model.dart'; import '../app_model.dart'; import '../connectivity_model.dart'; import 'master_detail_page.dart'; @@ -45,17 +46,20 @@ class _MusicPodScaffoldState extends State { Widget build(BuildContext context) { final playerToTheRight = context.mediaQuerySize.width > kSideBarThreshHold; final isFullScreen = watchPropertyValue((AppModel m) => m.fullWindowMode); + final enableDiscordRPC = + watchPropertyValue((SettingsModel m) => m.enableDiscordRPC); - if (allowDiscordRPC) { + if (allowDiscordRPC && enableDiscordRPC) { registerStreamHandler( select: (AppModel m) => m.isDiscordConnectedStream, handler: (context, snapshot, cancel) { - if (!snapshot.hasData || snapshot.hasError) return; - showSnackBar( - context: context, - duration: const Duration(seconds: 3), - content: _DiscordConnectContent(connected: snapshot.data == true), - ); + if (snapshot.data == true) { + showSnackBar( + context: context, + duration: const Duration(seconds: 3), + content: _DiscordConnectContent(connected: snapshot.data == true), + ); + } }, ); }