From 56b03f3e53c175cf19fcef89ec8d4bf0e2399178 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 17 Apr 2024 12:43:08 +0200 Subject: [PATCH] patch out discord --- lib/main.dart | 6 +- lib/pages/settings/sections/desktop.dart | 7 -- lib/provider/discord_provider.dart | 69 ------------------- .../proxy_playlist/player_listeners.dart | 1 - .../proxy_playlist_provider.dart | 3 - .../user_preferences_provider.dart | 4 -- .../user_preferences_state.dart | 1 - .../user_preferences_state.freezed.dart | 7 -- linux/flutter/generated_plugin_registrant.cc | 4 -- linux/flutter/generated_plugins.cmake | 1 - pubspec.lock | 9 --- pubspec.yaml | 3 - .../flutter/generated_plugin_registrant.cc | 3 - windows/flutter/generated_plugins.cmake | 1 - 14 files changed, 1 insertion(+), 118 deletions(-) delete mode 100644 lib/provider/discord_provider.dart diff --git a/lib/main.dart b/lib/main.dart index 0bb72932f..de4a2449a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,5 @@ import 'package:catcher_2/catcher_2.dart'; -import 'package:dart_discord_rpc/dart_discord_rpc.dart'; + import 'package:device_preview/device_preview.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -69,10 +69,6 @@ Future main(List rawArgs) async { MetadataGod.initialize(); } - if (DesktopTools.platform.isWindows || DesktopTools.platform.isLinux) { - DiscordRPC.initialize(); - } - await KVStoreService.initialize(); final hiveCacheDir = diff --git a/lib/pages/settings/sections/desktop.dart b/lib/pages/settings/sections/desktop.dart index 4e4408d9b..d6b168887 100644 --- a/lib/pages/settings/sections/desktop.dart +++ b/lib/pages/settings/sections/desktop.dart @@ -53,13 +53,6 @@ class SettingsDesktopSection extends HookConsumerWidget { value: preferences.systemTitleBar, onChanged: preferencesNotifier.setSystemTitleBar, ), - if (!DesktopTools.platform.isMacOS) - SwitchListTile( - secondary: const Icon(SpotubeIcons.discord), - title: Text(context.l10n.discord_rich_presence), - value: preferences.discordPresence, - onChanged: preferencesNotifier.setDiscordPresence, - ), ], ); } diff --git a/lib/provider/discord_provider.dart b/lib/provider/discord_provider.dart deleted file mode 100644 index ca8eecfa7..000000000 --- a/lib/provider/discord_provider.dart +++ /dev/null @@ -1,69 +0,0 @@ -import 'package:dart_discord_rpc/dart_discord_rpc.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:spotify/spotify.dart'; -import 'package:spotube/collections/env.dart'; -import 'package:spotube/extensions/artist_simple.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; - -class Discord extends ChangeNotifier { - final DiscordRPC? discordRPC; - final bool isEnabled; - - Discord(this.isEnabled) - : discordRPC = (DesktopTools.platform.isWindows || - DesktopTools.platform.isLinux) && - isEnabled - ? DiscordRPC(applicationId: Env.discordAppId) - : null { - discordRPC?.start(autoRegister: true); - } - - void updatePresence(Track track) { - clear(); - final artistNames = track.artists?.asString() ?? ""; - discordRPC?.updatePresence( - DiscordPresence( - details: "Song: ${track.name} by $artistNames", - state: "Vibing in Music", - startTimeStamp: DateTime.now().millisecondsSinceEpoch, - largeImageKey: "spotube-logo-foreground", - largeImageText: "Spotube", - smallImageKey: "spotube-logo-foreground", - smallImageText: "Spotube", - ), - ); - } - - void clear() { - discordRPC?.clearPresence(); - } - - void shutdown() { - discordRPC?.shutDown(); - } - - @override - void dispose() { - clear(); - shutdown(); - super.dispose(); - } -} - -final discordProvider = ChangeNotifierProvider( - (ref) { - final isEnabled = - ref.watch(userPreferencesProvider.select((s) => s.discordPresence)); - final playback = ref.read(proxyPlaylistProvider); - final discord = Discord(isEnabled); - - if (playback.activeTrack != null) { - discord.updatePresence(playback.activeTrack!); - } - - return discord; - }, -); diff --git a/lib/provider/proxy_playlist/player_listeners.dart b/lib/provider/proxy_playlist/player_listeners.dart index f86ad3d47..3a2ec033f 100644 --- a/lib/provider/proxy_playlist/player_listeners.dart +++ b/lib/provider/proxy_playlist/player_listeners.dart @@ -20,7 +20,6 @@ extension ProxyPlaylistListeners on ProxyPlaylistNotifier { ); notificationService.addTrack(state.activeTrack!); - discord.updatePresence(state.activeTrack!); updatePalette(); }); } diff --git a/lib/provider/proxy_playlist/proxy_playlist_provider.dart b/lib/provider/proxy_playlist/proxy_playlist_provider.dart index 9811a1f8e..06836bd8a 100644 --- a/lib/provider/proxy_playlist/proxy_playlist_provider.dart +++ b/lib/provider/proxy_playlist/proxy_playlist_provider.dart @@ -19,7 +19,6 @@ import 'package:spotube/provider/user_preferences/user_preferences_provider.dart import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; import 'package:spotube/services/audio_services/audio_services.dart'; -import 'package:spotube/provider/discord_provider.dart'; import 'package:spotube/utils/persisted_state_notifier.dart'; @@ -31,7 +30,6 @@ class ProxyPlaylistNotifier extends PersistedStateNotifier { UserPreferences get preferences => ref.read(userPreferencesProvider); ProxyPlaylist get playlist => state; BlackListNotifier get blacklist => ref.read(blacklistProvider.notifier); - Discord get discord => ref.read(discordProvider); List _subscriptions = []; @@ -164,7 +162,6 @@ class ProxyPlaylistNotifier extends PersistedStateNotifier { Future stop() async { state = ProxyPlaylist({}); await audioPlayer.stop(); - discord.clear(); } Future updatePalette() async { diff --git a/lib/provider/user_preferences/user_preferences_provider.dart b/lib/provider/user_preferences/user_preferences_provider.dart index a1e247b22..b4cd914d0 100644 --- a/lib/provider/user_preferences/user_preferences_provider.dart +++ b/lib/provider/user_preferences/user_preferences_provider.dart @@ -110,10 +110,6 @@ class UserPreferencesNotifier extends PersistedStateNotifier { } } - void setDiscordPresence(bool discordPresence) { - state = state.copyWith(discordPresence: discordPresence); - } - void setAmoledDarkTheme(bool isAmoled) { state = state.copyWith(amoledDarkTheme: isAmoled); } diff --git a/lib/provider/user_preferences/user_preferences_state.dart b/lib/provider/user_preferences/user_preferences_state.dart index e35c73b5e..88716a93a 100644 --- a/lib/provider/user_preferences/user_preferences_state.dart +++ b/lib/provider/user_preferences/user_preferences_state.dart @@ -89,7 +89,6 @@ class UserPreferences with _$UserPreferences { @Default(AudioSource.youtube) AudioSource audioSource, @Default(SourceCodecs.weba) SourceCodecs streamMusicCodec, @Default(SourceCodecs.m4a) SourceCodecs downloadMusicCodec, - @Default(true) bool discordPresence, @Default(true) bool endlessPlayback, @Default(false) bool enableConnect, }) = _UserPreferences; diff --git a/lib/provider/user_preferences/user_preferences_state.freezed.dart b/lib/provider/user_preferences/user_preferences_state.freezed.dart index a5b076bb6..9f5f0eb17 100644 --- a/lib/provider/user_preferences/user_preferences_state.freezed.dart +++ b/lib/provider/user_preferences/user_preferences_state.freezed.dart @@ -48,7 +48,6 @@ mixin _$UserPreferences { AudioSource get audioSource => throw _privateConstructorUsedError; SourceCodecs get streamMusicCodec => throw _privateConstructorUsedError; SourceCodecs get downloadMusicCodec => throw _privateConstructorUsedError; - bool get discordPresence => throw _privateConstructorUsedError; bool get endlessPlayback => throw _privateConstructorUsedError; bool get enableConnect => throw _privateConstructorUsedError; @@ -93,7 +92,6 @@ abstract class $UserPreferencesCopyWith<$Res> { AudioSource audioSource, SourceCodecs streamMusicCodec, SourceCodecs downloadMusicCodec, - bool discordPresence, bool endlessPlayback, bool enableConnect}); } @@ -131,7 +129,6 @@ class _$UserPreferencesCopyWithImpl<$Res, $Val extends UserPreferences> Object? audioSource = null, Object? streamMusicCodec = null, Object? downloadMusicCodec = null, - Object? discordPresence = null, Object? endlessPlayback = null, Object? enableConnect = null, }) { @@ -216,10 +213,6 @@ class _$UserPreferencesCopyWithImpl<$Res, $Val extends UserPreferences> ? _value.downloadMusicCodec : downloadMusicCodec // ignore: cast_nullable_to_non_nullable as SourceCodecs, - discordPresence: null == discordPresence - ? _value.discordPresence - : discordPresence // ignore: cast_nullable_to_non_nullable - as bool, endlessPlayback: null == endlessPlayback ? _value.endlessPlayback : endlessPlayback // ignore: cast_nullable_to_non_nullable diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index c69c17c01..a39835bf5 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,7 +6,6 @@ #include "generated_plugin_registrant.h" -#include #include #include #include @@ -20,9 +19,6 @@ #include void fl_register_plugins(FlPluginRegistry* registry) { - g_autoptr(FlPluginRegistrar) dart_discord_rpc_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "DartDiscordRpcPlugin"); - dart_discord_rpc_plugin_register_with_registrar(dart_discord_rpc_registrar); g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); file_selector_plugin_register_with_registrar(file_selector_linux_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index a4487f4d0..dbcdb2798 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,7 +3,6 @@ # list(APPEND FLUTTER_PLUGIN_LIST - dart_discord_rpc file_selector_linux flutter_secure_storage_linux gtk diff --git a/pubspec.lock b/pubspec.lock index 8d19f604c..403899b90 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -497,15 +497,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.2" - dart_discord_rpc: - dependency: "direct main" - description: - path: "." - ref: HEAD - resolved-ref: "4d05017838ebeadcdb832e1893fabad1506fddba" - url: "https://github.com/Tommypop2/dart_discord_rpc.git" - source: git - version: "0.0.3" dart_style: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 3f4c22af3..ba07a2866 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -111,9 +111,6 @@ dependencies: very_good_infinite_list: ^0.7.1 gap: ^3.0.1 sliver_tools: ^0.2.12 - dart_discord_rpc: - git: - url: https://github.com/Tommypop2/dart_discord_rpc.git html_unescape: ^2.0.0 wikipedia_api: ^0.1.0 skeletonizer: ^0.8.0 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index d8a9db298..7e761673a 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -26,8 +25,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("AppLinksPluginCApi")); BonsoirWindowsPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("BonsoirWindowsPluginCApi")); - DartDiscordRpcPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("DartDiscordRpcPlugin")); FileSelectorWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("FileSelectorWindows")); FlutterSecureStorageWindowsPluginRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 902927444..d40394d8b 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -5,7 +5,6 @@ list(APPEND FLUTTER_PLUGIN_LIST app_links bonsoir_windows - dart_discord_rpc file_selector_windows flutter_secure_storage_windows local_notifier