Skip to content

Commit

Permalink
fix: lyrics not changing on track change
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Jan 31, 2023
1 parent 3db28f4 commit c809d2d
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class SpotubeState extends ConsumerState<Spotube> with WidgetsBindingObserver {
'height': size.height,
}),
);
prevSize = await windowManager.getSize();
prevSize = size;
}

TargetPlatform appPlatform = TargetPlatform.android;
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/lyrics/genius_lyrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class GeniusLyrics extends HookConsumerWidget {
Widget build(BuildContext context, ref) {
Playback playback = ref.watch(playbackProvider);
final geniusLyricsQuery = useQuery(
job: Queries.lyrics.static,
job: Queries.lyrics.static(playback.track?.id ?? ""),
externalData: Tuple2(
playback.track,
ref.watch(userPreferencesProvider).geniusAccessToken,
Expand Down
5 changes: 3 additions & 2 deletions lib/pages/lyrics/lyrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ class LyricsPage extends HookConsumerWidget {
return SafeArea(
child: Container(
clipBehavior: Clip.hardEdge,
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
decoration: BoxDecoration(
color: Theme.of(context).backgroundColor.withOpacity(.4),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/lyrics/synced_lyrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SyncedLyrics extends HookConsumerWidget {
Widget build(BuildContext context, ref) {
Playback playback = ref.watch(playbackProvider);
final timedLyricsQuery = useQuery(
job: Queries.lyrics.synced,
job: Queries.lyrics.synced(playback.track?.id ?? ""),
externalData: playback.track,
);
final lyricDelay = ref.watch(lyricDelayState);
Expand Down
18 changes: 10 additions & 8 deletions lib/services/queries/lyrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import 'package:spotube/utils/service_utils.dart';
import 'package:tuple/tuple.dart';

class LyricsQueries {
final static = QueryJob<String, Tuple2<Track?, String>>(
queryKey: "genius-lyrics-query",
final static = QueryJob.withVariableKey<String, Tuple2<Track?, String>>(
preQueryKey: "genius-lyrics-query",
refetchOnExternalDataChange: true,
task: (_, externalData) async {
task: (queryKey, externalData) async {
final currentTrack = externalData.item1;
final geniusAccessToken = externalData.item2;
if (currentTrack == null) {
if (currentTrack == null || getVariable(queryKey).isEmpty) {
return "“Give this player a track to play”\n- S'Challa";
}
final lyrics = await ServiceUtils.getLyrics(
Expand All @@ -28,10 +28,12 @@ class LyricsQueries {
},
);

final synced = QueryJob<SubtitleSimple, SpotubeTrack?>(
queryKey: "synced-lyrics",
task: (_, currentTrack) async {
if (currentTrack == null) throw "No track currently";
final synced = QueryJob.withVariableKey<SubtitleSimple, SpotubeTrack?>(
preQueryKey: "synced-lyrics",
task: (queryKey, currentTrack) async {
if (currentTrack == null || getVariable(queryKey).isEmpty) {
throw "No track currently";
}

final timedLyrics = await ServiceUtils.getTimedLyrics(currentTrack);
if (timedLyrics == null) throw Exception("Unable to find lyrics");
Expand Down
4 changes: 2 additions & 2 deletions lib/themes/dark_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ ThemeData darkTheme({
indicatorColor: accentMaterialColor[300],
),
navigationBarTheme: NavigationBarThemeData(
backgroundColor: backgroundMaterialColor[800],
height: 55,
backgroundColor: backgroundMaterialColor[900],
height: 45,
indicatorColor: accentMaterialColor[300],
labelBehavior: NavigationDestinationLabelBehavior.alwaysHide,
iconTheme: MaterialStateProperty.resolveWith((states) {
Expand Down
4 changes: 2 additions & 2 deletions lib/themes/light_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ ThemeData lightTheme({
),
),
navigationBarTheme: NavigationBarThemeData(
backgroundColor: backgroundMaterialColor[100],
height: 55,
backgroundColor: backgroundMaterialColor[50],
height: 45,
indicatorColor: accentMaterialColor[300],
iconTheme: MaterialStateProperty.all(
IconThemeData(color: Colors.grey[850], size: 18),
Expand Down

0 comments on commit c809d2d

Please sign in to comment.