diff --git a/lib/modules/root/bottom_player.dart b/lib/modules/root/bottom_player.dart index 7f37c4720..a2f454491 100644 --- a/lib/modules/root/bottom_player.dart +++ b/lib/modules/root/bottom_player.dart @@ -17,7 +17,6 @@ import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; import 'package:spotube/hooks/utils/use_brightness_value.dart'; import 'package:flutter/material.dart'; -import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; @@ -30,7 +29,6 @@ class BottomPlayer extends HookConsumerWidget { @override Widget build(BuildContext context, ref) { - final auth = ref.watch(authenticationProvider); final playlist = ref.watch(audioPlayerProvider); final layoutMode = ref.watch(userPreferencesProvider.select((s) => s.layoutMode)); @@ -89,35 +87,34 @@ class BottomPlayer extends HookConsumerWidget { children: [ PlayerActions( extraActions: [ - if (auth.asData?.value != null) - IconButton( - tooltip: context.l10n.mini_player, - icon: const Icon(SpotubeIcons.miniPlayer), - onPressed: () async { - if (!kIsDesktop) return; + IconButton( + tooltip: context.l10n.mini_player, + icon: const Icon(SpotubeIcons.miniPlayer), + onPressed: () async { + if (!kIsDesktop) return; - final prevSize = await windowManager.getSize(); - await windowManager.setMinimumSize( - const Size(300, 300), - ); - await windowManager.setAlwaysOnTop(true); - if (!kIsLinux) { - await windowManager.setHasShadow(false); - } - await windowManager - .setAlignment(Alignment.topRight); - await windowManager.setSize(const Size(400, 500)); - await Future.delayed( - const Duration(milliseconds: 100), - () async { - GoRouter.of(context).go( - '/mini-player', - extra: prevSize, - ); - }, - ); - }, - ), + final prevSize = await windowManager.getSize(); + await windowManager.setMinimumSize( + const Size(300, 300), + ); + await windowManager.setAlwaysOnTop(true); + if (!kIsLinux) { + await windowManager.setHasShadow(false); + } + await windowManager + .setAlignment(Alignment.topRight); + await windowManager.setSize(const Size(400, 500)); + await Future.delayed( + const Duration(milliseconds: 100), + () async { + GoRouter.of(context).go( + '/mini-player', + extra: prevSize, + ); + }, + ); + }, + ), ], ), Container( diff --git a/lib/pages/lyrics/lyrics.dart b/lib/pages/lyrics/lyrics.dart index a81e3ba6c..423212f39 100644 --- a/lib/pages/lyrics/lyrics.dart +++ b/lib/pages/lyrics/lyrics.dart @@ -6,7 +6,6 @@ import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/fallbacks/anonymous_fallback.dart'; import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/components/image/universal_image.dart'; import 'package:spotube/components/themed_button_tab_bar.dart'; @@ -17,7 +16,6 @@ import 'package:spotube/hooks/utils/use_custom_status_bar_color.dart'; import 'package:spotube/hooks/utils/use_palette_color.dart'; import 'package:spotube/pages/lyrics/plain_lyrics.dart'; import 'package:spotube/pages/lyrics/synced_lyrics.dart'; -import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/utils/platform.dart'; import 'package:spotube/provider/spotify/spotify.dart'; @@ -82,15 +80,6 @@ class LyricsPage extends HookConsumerWidget { ), ); - final auth = ref.watch(authenticationProvider); - - if (auth.asData?.value == null) { - return Scaffold( - appBar: !kIsMacOS && !isModal ? const PageWindowTitleBar() : null, - body: const AnonymousFallback(), - ); - } - if (isModal) { return DefaultTabController( length: 2, diff --git a/lib/pages/lyrics/mini_lyrics.dart b/lib/pages/lyrics/mini_lyrics.dart index dbff563df..8f6ec1fc2 100644 --- a/lib/pages/lyrics/mini_lyrics.dart +++ b/lib/pages/lyrics/mini_lyrics.dart @@ -8,13 +8,10 @@ import 'package:spotube/collections/spotube_icons.dart'; import 'package:spotube/modules/player/player_controls.dart'; import 'package:spotube/modules/player/player_queue.dart'; import 'package:spotube/modules/root/sidebar.dart'; -import 'package:spotube/components/fallbacks/anonymous_fallback.dart'; -import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/hooks/utils/use_force_update.dart'; import 'package:spotube/pages/lyrics/plain_lyrics.dart'; import 'package:spotube/pages/lyrics/synced_lyrics.dart'; -import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/utils/platform.dart'; import 'package:window_manager/window_manager.dart'; @@ -46,14 +43,7 @@ class MiniLyricsPage extends HookConsumerWidget { return null; }, []); - final auth = ref.watch(authenticationProvider); - - if (auth.asData?.value == null) { - return const Scaffold( - appBar: PageWindowTitleBar(), - body: AnonymousFallback(), - ); - } + return MouseRegion( onEnter: !hoverMode.value diff --git a/lib/pages/lyrics/synced_lyrics.dart b/lib/pages/lyrics/synced_lyrics.dart index d7f7685a7..59bd863ad 100644 --- a/lib/pages/lyrics/synced_lyrics.dart +++ b/lib/pages/lyrics/synced_lyrics.dart @@ -82,7 +82,7 @@ class SyncedLyrics extends HookConsumerWidget { WidgetsBinding.instance.addPostFrameCallback((_) { subscription = audioPlayer.positionStream.listen((event) { try { - if (event > Duration.zero) return; + if (event > Duration.zero || !controller.hasClients) return; controller.animateTo( 0, duration: const Duration(milliseconds: 500), diff --git a/lib/provider/spotify/lyrics/synced.dart b/lib/provider/spotify/lyrics/synced.dart index 085fccb7f..c6c0d6e31 100644 --- a/lib/provider/spotify/lyrics/synced.dart +++ b/lib/provider/spotify/lyrics/synced.dart @@ -125,6 +125,7 @@ class SyncedLyricsNotifier extends FamilyAsyncNotifier { try { final database = ref.watch(databaseProvider); final spotify = ref.watch(spotifyProvider); + final auth = await ref.watch(authenticationProvider.future); if (track == null) { throw "No track currently"; @@ -139,11 +140,13 @@ class SyncedLyricsNotifier extends FamilyAsyncNotifier { final token = await spotify.getCredentials(); - if (lyrics == null || lyrics.lyrics.isEmpty) { + if ((lyrics == null || lyrics.lyrics.isEmpty) && auth != null) { lyrics = await getSpotifyLyrics(token.accessToken); } - if (lyrics.lyrics.isEmpty || lyrics.lyrics.length <= 5) { + if (lyrics == null || + lyrics.lyrics.isEmpty || + lyrics.lyrics.length <= 5) { lyrics = await getLRCLibLyrics(); } diff --git a/lib/provider/spotify/spotify.dart b/lib/provider/spotify/spotify.dart index 5997a47a6..8cf601201 100644 --- a/lib/provider/spotify/spotify.dart +++ b/lib/provider/spotify/spotify.dart @@ -4,6 +4,7 @@ import 'dart:async'; import 'package:drift/drift.dart'; import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/database/database.dart'; import 'package:spotube/provider/spotify/utils/json_cast.dart'; import 'package:spotube/services/logger/logger.dart';