From 23879776719f3dcba3f0f7b5b537ee739ec9b4ed Mon Sep 17 00:00:00 2001 From: Frederik Feichtmeier Date: Sun, 20 Oct 2024 07:44:26 +0200 Subject: [PATCH] fix: do not retry connect to discord, update deps (#962) --- lib/app/view/scaffold.dart | 68 +++++--- lib/app_config.dart | 1 + lib/common/view/icons.dart | 6 + lib/expose/expose_service.dart | 9 +- lib/player/player_service.dart | 6 +- lib/player/view/bottom_player_image.dart | 8 +- .../view/full_height_player_top_controls.dart | 2 +- macos/Podfile.lock | 9 +- pubspec.lock | 153 +++++++++--------- pubspec.yaml | 9 +- 10 files changed, 149 insertions(+), 122 deletions(-) diff --git a/lib/app/view/scaffold.dart b/lib/app/view/scaffold.dart index d44eea95b..3a98657c9 100644 --- a/lib/app/view/scaffold.dart +++ b/lib/app/view/scaffold.dart @@ -3,6 +3,7 @@ import 'package:flutter_tabler_icons/flutter_tabler_icons.dart'; import 'package:watch_it/watch_it.dart'; import 'package:yaru/yaru.dart'; +import '../../app_config.dart'; import '../../common/view/snackbars.dart'; import '../../common/view/theme.dart'; import '../../constants.dart'; @@ -44,32 +45,20 @@ class _MusicPodScaffoldState extends State { Widget build(BuildContext context) { final playerToTheRight = context.mediaQuerySize.width > kSideBarThreshHold; final isFullScreen = watchPropertyValue((AppModel m) => m.fullWindowMode); - final l10n = context.l10n; - registerStreamHandler( - select: (AppModel m) => m.isDiscordConnectedStream, - handler: (context, snapshot, cancel) { - if (!snapshot.hasData || snapshot.hasError) return; - showSnackBar( - context: context, - content: Row( - mainAxisSize: MainAxisSize.min, - children: space( - widthGap: 10, - children: [ - Text( - '${snapshot.data == true ? l10n.connectedTo : l10n.disconnectedFrom}' - ' ${l10n.exposeToDiscordTitle}', - ), - Icon( - TablerIcons.brand_discord_filled, - color: context.theme.primaryColor, - ), - ], - ), - ), - ); - }, - ); + + if (allowDiscordRPC) { + 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), + ); + }, + ); + } return Stack( alignment: Alignment.center, @@ -98,3 +87,30 @@ class _MusicPodScaffoldState extends State { ); } } + +class _DiscordConnectContent extends StatelessWidget { + const _DiscordConnectContent({required this.connected}); + + final bool connected; + + @override + Widget build(BuildContext context) { + final l10n = context.l10n; + return Row( + mainAxisSize: MainAxisSize.min, + children: space( + widthGap: 10, + children: [ + Text( + '${connected ? l10n.connectedTo : l10n.disconnectedFrom}' + ' ${l10n.exposeToDiscordTitle}', + ), + Icon( + TablerIcons.brand_discord_filled, + color: context.theme.primaryColor, + ), + ], + ), + ); + } +} diff --git a/lib/app_config.dart b/lib/app_config.dart index 885f8f2f7..a3f9ca06b 100644 --- a/lib/app_config.dart +++ b/lib/app_config.dart @@ -7,4 +7,5 @@ import 'package:flutter/foundation.dart'; bool allowDiscordRPC = kDebugMode || Platform.isMacOS || Platform.isWindows || + Platform.isLinux || bool.tryParse(const String.fromEnvironment('ALLOW_DISCORD_RPC')) == true; diff --git a/lib/common/view/icons.dart b/lib/common/view/icons.dart index 4b8001592..5bb1dfe50 100644 --- a/lib/common/view/icons.dart +++ b/lib/common/view/icons.dart @@ -5,6 +5,12 @@ import 'package:yaru/yaru.dart'; import 'theme.dart'; class Iconz { + static IconData get image => yaruStyled + ? YaruIcons.image + : appleStyled + ? CupertinoIcons.photo + : Icons.image_not_supported; + static IconData get warning => yaruStyled ? YaruIcons.warning_filled : appleStyled diff --git a/lib/expose/expose_service.dart b/lib/expose/expose_service.dart index 2c053548a..29faf53ef 100644 --- a/lib/expose/expose_service.dart +++ b/lib/expose/expose_service.dart @@ -20,7 +20,7 @@ class ExposeService { }) async { try { if (_discordRPC?.isConnected == false) { - await _discordRPC?.connect(autoRetry: true); + await _discordRPC?.connect(); } if (_discordRPC?.isConnected == true) { await _discordRPC?.setActivity( @@ -37,8 +37,11 @@ class ExposeService { } on Exception catch (_) {} } - Future connectToDiscord() async => - _discordRPC?.connect(autoRetry: true); + Future connect() async { + await connectToDiscord(); + } + + Future connectToDiscord() async => _discordRPC?.connect(); Future disconnectFromDiscord() async => _discordRPC?.disconnect(); diff --git a/lib/player/player_service.dart b/lib/player/player_service.dart index 37cd389d5..155d503e4 100644 --- a/lib/player/player_service.dart +++ b/lib/player/player_service.dart @@ -610,13 +610,13 @@ class PlayerService { case PressedButton.play: playOrPause().then( (_) => _smtc?.setPlaybackStatus( - _isPlaying ? PlaybackStatus.Playing : PlaybackStatus.Paused, + _isPlaying ? PlaybackStatus.playing : PlaybackStatus.paused, ), ); case PressedButton.pause: playOrPause().then( (_) => _smtc?.setPlaybackStatus( - _isPlaying ? PlaybackStatus.Playing : PlaybackStatus.Paused, + _isPlaying ? PlaybackStatus.playing : PlaybackStatus.paused, ), ); case PressedButton.next: @@ -727,7 +727,7 @@ class PlayerService { ); } else if (_smtc != null) { _smtc!.setPlaybackStatus( - playing ? PlaybackStatus.Playing : PlaybackStatus.Paused, + playing ? PlaybackStatus.playing : PlaybackStatus.paused, ); } } diff --git a/lib/player/view/bottom_player_image.dart b/lib/player/view/bottom_player_image.dart index 6de7d30b3..7860aeb1b 100644 --- a/lib/player/view/bottom_player_image.dart +++ b/lib/player/view/bottom_player_image.dart @@ -90,7 +90,13 @@ class BottomPlayerImage extends StatelessWidget with WatchItMixin { padding: const EdgeInsets.only(left: 5), child: Tooltip( message: context.l10n.onlineArtError, - child: Icon(Iconz.warning, color: Colors.yellowAccent), + child: Icon( + Iconz.imageMissingFilled, + color: Colors.white, + shadows: [ + const BoxShadow(offset: Offset(0, 1), blurRadius: 1), + ], + ), ), ), ), diff --git a/lib/player/view/full_height_player_top_controls.dart b/lib/player/view/full_height_player_top_controls.dart index 0b991253e..d49342431 100644 --- a/lib/player/view/full_height_player_top_controls.dart +++ b/lib/player/view/full_height_player_top_controls.dart @@ -64,7 +64,7 @@ class FullHeightPlayerTopControls extends StatelessWidget with WatchItMixin { snackBar: SnackBar(content: Text(context.l10n.onlineArtError)), ), icon: Icon( - Iconz.warning, + Iconz.imageMissingFilled, color: context.theme.colorScheme.onSurface, ), ), diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 4552f704d..f5f847469 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -10,7 +10,8 @@ PODS: - FlutterMacOS - file_selector_macos (0.0.1): - FlutterMacOS - - flutter_discord_rpc (0.0.1) + - flutter_discord_rpc (0.0.1): + - FlutterMacOS - FlutterMacOS (1.0.0) - irondash_engine_context (0.0.1): - FlutterMacOS @@ -119,16 +120,16 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: audio_service: b88ff778e0e3915efd4cd1a5ad6f0beef0c950a9 audio_session: dea1f41890dbf1718f04a56f1d6150fd50039b72 - connectivity_plus: ddd7f30999e1faaef5967c23d5b6d503d10434db + connectivity_plus: 4c41c08fc6d7c91f63bc7aec70ffe3730b04f563 device_info_plus: ce1b7762849d3ec103d0e0517299f2db7ad60720 file_selector_macos: cc3858c981fe6889f364731200d6232dac1d812d - flutter_discord_rpc: 53b006f68ef620a99fe1b3ba7e83513f3ae95b4c + flutter_discord_rpc: 67a7c10ea24d9d3bf35d01af643f48fbcfa7c24f FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 irondash_engine_context: da62996ee25616d2f01bbeb85dc115d813359478 media_kit_libs_macos_video: b3e2bbec2eef97c285f2b1baa7963c67c753fb82 media_kit_native_event_loop: 81fd5b45192b72f8b5b69eaf5b540f45777eb8d5 media_kit_video: c75b07f14d59706c775778e4dd47dd027de8d1e5 - package_info_plus: d2f71247aab4b6521434f887276093acc70d214c + package_info_plus: f5790acc797bf17c3e959e9d6cf162cc68ff7523 path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 screen_brightness_macos: 2d6d3af2165592d9a55ffcd95b7550970e41ebda screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38 diff --git a/pubspec.lock b/pubspec.lock index 83f051547..ad68e0bca 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -58,10 +58,18 @@ packages: dependency: transitive description: name: args - sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a" + sha256: bf9f5caeea8d8fe6721a9c358dd8a5c1947b27f1cfaa18b39c301273594919e6 url: "https://pub.dev" source: hosted - version: "2.5.0" + version: "2.6.0" + assorted_layout_widgets: + dependency: transitive + description: + name: assorted_layout_widgets + sha256: "5b7f7c76a1a4c7cf95edfb854c3ed09ce9cb7f25a372f2d9a8d4c1569d42ecfb" + url: "https://pub.dev" + source: hosted + version: "9.0.2" async: dependency: transitive description: @@ -291,10 +299,10 @@ packages: dependency: "direct main" description: name: connectivity_plus - sha256: "2056db5241f96cdc0126bd94459fc4cdc13876753768fc7a31c425e50a7177d0" + sha256: "876849631b0c7dc20f8b471a2a03142841b482438e3b707955464f5ffca3e4c3" url: "https://pub.dev" source: hosted - version: "6.0.5" + version: "6.1.0" connectivity_plus_platform_interface: dependency: transitive description: @@ -307,10 +315,10 @@ packages: dependency: transitive description: name: convert - sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "3.1.2" cross_file: dependency: transitive description: @@ -323,10 +331,10 @@ packages: dependency: transitive description: name: crypto - sha256: ec30d999af904f33454ba22ed9a86162b35e52b44ac4807d1d93c288041d7d27 + sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.6" csslib: dependency: transitive description: @@ -435,10 +443,10 @@ packages: dependency: "direct main" description: name: file_picker - sha256: "167bb619cdddaa10ef2907609feb8a79c16dfa479d3afaf960f8e223f754bf12" + sha256: aac85f20436608e01a6ffd1fdd4e746a7f33c93a2c83752e626bdfaea139b877 url: "https://pub.dev" source: hosted - version: "8.1.2" + version: "8.1.3" file_selector: dependency: "direct main" description: @@ -507,10 +515,10 @@ packages: dependency: transitive description: name: fixnum - sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" flutter: dependency: "direct main" description: flutter @@ -527,12 +535,11 @@ packages: flutter_discord_rpc: dependency: "direct main" description: - path: "packages/flutter_discord_rpc" - ref: "9d5764ee143aef23517bd578fc1b3a2d83d67a44" - resolved-ref: "9d5764ee143aef23517bd578fc1b3a2d83d67a44" - url: "https://github.com/ubuntu-flutter-community/frb_plugins" - source: git - version: "0.1.0+1" + name: flutter_discord_rpc + sha256: "9363a803863d56fd89c0a21639c70b126245fcbafaeb0a3d091e7ac06951d03f" + url: "https://pub.dev" + source: hosted + version: "1.0.0" flutter_html: dependency: "direct main" description: @@ -558,10 +565,10 @@ packages: dependency: "direct main" description: name: flutter_markdown - sha256: e17575ca576a34b46c58c91f9948891117a1bd97815d2e661813c7f90c647a78 + sha256: bd9c475d9aae256369edacafc29d1e74c81f78a10cdcdacbbbc9e3c43d009e4a url: "https://pub.dev" source: hosted - version: "0.7.3+2" + version: "0.7.4" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -574,10 +581,10 @@ packages: dependency: transitive description: name: flutter_rust_bridge - sha256: "02720226035257ad0b571c1256f43df3e1556a499f6bcb004849a0faaa0e87f0" + sha256: "0ad5079de35d317650fec59b26cb4d0c116ebc2ce703a29f9367513b8a91c287" url: "https://pub.dev" source: hosted - version: "1.82.6" + version: "2.5.0" flutter_staggered_grid_view: dependency: transitive description: @@ -712,10 +719,10 @@ packages: dependency: transitive description: name: image - sha256: "2237616a36c0d69aef7549ab439b833fb7f9fb9fc861af2cc9ac3eedddd69ca8" + sha256: f31d52537dc417fdcde36088fdf11d191026fd5e4fae742491ebd40e5a8bea7d url: "https://pub.dev" source: hosted - version: "4.2.0" + version: "4.3.0" intl: dependency: "direct main" description: @@ -808,18 +815,18 @@ packages: dependency: transitive description: name: logging - sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" lottie: dependency: transitive description: name: lottie - sha256: "6a24ade5d3d918c306bb1c21a6b9a04aab0489d51a2582522eea820b4093b62b" + sha256: "7afc60865a2429d994144f7d66ced2ae4305fe35d82890b8766e3359872d872c" url: "https://pub.dev" source: hosted - version: "3.1.2" + version: "3.1.3" m3u_parser_nullsafe: dependency: "direct main" description: @@ -860,6 +867,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.11.1" + matrix4_transform: + dependency: transitive + description: + name: matrix4_transform + sha256: "42c42610deecc382be2653f4a21358537401bd5b027c168a174c7c6a64959908" + url: "https://pub.dev" + source: hosted + version: "3.0.1" media_kit: dependency: "direct main" description: @@ -986,10 +1001,10 @@ packages: dependency: "direct main" description: name: package_info_plus - sha256: "894f37107424311bdae3e476552229476777b8752c5a2a2369c0cb9a2d5442ef" + sha256: df3eb3e0aed5c1107bb0fdb80a8e82e778114958b1c5ac5644fb1ac9cae8a998 url: "https://pub.dev" source: hosted - version: "8.0.3" + version: "8.1.0" package_info_plus_platform_interface: dependency: transitive description: @@ -1099,10 +1114,10 @@ packages: dependency: transitive description: name: platform - sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65" + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" url: "https://pub.dev" source: hosted - version: "3.1.5" + version: "3.1.6" platform_linux: dependency: transitive description: @@ -1167,14 +1182,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" - puppeteer: - dependency: transitive - description: - name: puppeteer - sha256: fc33b2a12731e0b9e16c40cd91ea2b6886bcc24037a435fceb59b786d4074f2b - url: "https://pub.dev" - source: hosted - version: "3.15.0" radio_browser_api: dependency: "direct main" description: @@ -1351,22 +1358,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.4.1" - shelf_static: - dependency: transitive - description: - name: shelf_static - sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3 - url: "https://pub.dev" - source: hosted - version: "1.1.3" shelf_web_socket: dependency: transitive description: name: shelf_web_socket - sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + sha256: "073c147238594ecd0d193f3456a5fe91c4b0abbcc68bf5cd95b36c4e194ac611" url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "2.0.0" shimmer: dependency: "direct main" description: @@ -1384,10 +1383,10 @@ packages: dependency: "direct main" description: name: smtc_windows - sha256: "0fd64d0c6a0c8ea4ea7908d31195eadc8f6d45d5245159fc67259e9e8704100f" + sha256: "80f7c10867da485ffdf87f842bf27e6763589933c18c11af5dc1cd1e158c3154" url: "https://pub.dev" source: hosted - version: "0.1.3" + version: "1.0.0" source_gen: dependency: transitive description: @@ -1496,26 +1495,26 @@ packages: dependency: transitive description: name: super_clipboard - sha256: bfbfc602becb256c675c37332a0c5083a870f20806092938a247c36b3d6ecb88 + sha256: "4a6ae6dfaa282ec1f2bff750976f535517ed8ca842d5deae13985eb11c00ac1f" url: "https://pub.dev" source: hosted - version: "0.8.23" + version: "0.8.24" super_drag_and_drop: dependency: "direct main" description: name: super_drag_and_drop - sha256: f145e9cb129197f646a5e0e1dc6e97d70a521345354c1cf303e66482969782c6 + sha256: e1ea1528916a728b3d0c3007c0af1303947026011f78564279af68d8856a0205 url: "https://pub.dev" source: hosted - version: "0.8.23" + version: "0.8.24" super_native_extensions: dependency: transitive description: name: super_native_extensions - sha256: "8fe12946dbee374937eacb8aea2658369e66306708319675fda641f7f13874ac" + sha256: a433bba8186cd6b707560c42535bf284804665231c00bca86faf1aa4968b7637 url: "https://pub.dev" source: hosted - version: "0.8.23" + version: "0.8.24" synchronized: dependency: transitive description: @@ -1564,22 +1563,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" - tuple: - dependency: transitive - description: - name: tuple - sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151 - url: "https://pub.dev" - source: hosted - version: "2.0.2" typed_data: dependency: transitive description: name: typed_data - sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 url: "https://pub.dev" source: hosted - version: "1.3.2" + version: "1.4.0" universal_platform: dependency: transitive description: @@ -1656,12 +1647,12 @@ packages: dependency: transitive description: name: url_launcher_windows - sha256: "49c10f879746271804767cb45551ec5592cdab00ee105c06dddde1a98f73b185" + sha256: "44cf3aabcedde30f2dba119a9dea3b0f2672fbe6fa96e85536251d678216b3c4" url: "https://pub.dev" source: hosted - version: "3.1.2" + version: "3.1.3" uuid: - dependency: "direct overridden" + dependency: transitive description: name: uuid sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff @@ -1732,22 +1723,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" + web_socket: + dependency: transitive + description: + name: web_socket + sha256: "3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83" + url: "https://pub.dev" + source: hosted + version: "0.1.6" web_socket_channel: dependency: transitive description: name: web_socket_channel - sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b + sha256: "9f187088ed104edd8662ca07af4b124465893caf063ba29758f97af57e61da8f" url: "https://pub.dev" source: hosted - version: "2.4.0" + version: "3.0.1" win32: dependency: "direct main" description: name: win32 - sha256: e5c39a90447e7c81cfec14b041cdbd0d0916bd9ebbc7fe02ab69568be703b9bd + sha256: "2735daae5150e8b1dfeb3eb0544b4d3af0061e9e82cef063adcd583bdae4306a" url: "https://pub.dev" source: hosted - version: "5.6.0" + version: "5.7.0" win32_registry: dependency: transitive description: @@ -1792,10 +1791,10 @@ packages: dependency: "direct main" description: name: yaru - sha256: "9e07131b9c3b9997d7784c3cb6ad24a218f8e0507d82f8fb07b7e160e111236d" + sha256: b226f045d3104422d7f4d87572cc57c75b7d5695adf6fa47dbab3bc664714e69 url: "https://pub.dev" source: hosted - version: "5.2.1" + version: "5.3.1" yaru_window: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index cac293a7f..967671db9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -31,11 +31,7 @@ dependencies: flutter: sdk: flutter flutter_cache_manager: ^3.4.1 - flutter_discord_rpc: - git: - url: https://github.com/ubuntu-flutter-community/frb_plugins - path: packages/flutter_discord_rpc - ref: 9d5764ee143aef23517bd578fc1b3a2d83d67a44 + flutter_discord_rpc: ^1.0.0 flutter_html: ^3.0.0-beta.2 flutter_localizations: sdk: flutter @@ -71,7 +67,7 @@ dependencies: scroll_to_index: ^3.0.1 shared_preferences: ^2.3.1 shimmer: ^3.0.0 - smtc_windows: ^0.1.3 + smtc_windows: ^1.0.0 super_drag_and_drop: ^0.8.18 system_theme: ^3.0.0 url_launcher: ^6.3.0 @@ -110,4 +106,3 @@ dependency_overrides: url: https://github.com/media-kit/media-kit path: media_kit_video/ ref: 13f6b3f0ef9ccf8a711e396bc49cb05af9b3e497 - uuid: ^4.1.0