Skip to content

Commit

Permalink
fix: lyrics not refetching when tracked changed while being in anothe…
Browse files Browse the repository at this point in the history
…r page and sidebar user avatar not showing on startup
  • Loading branch information
KRTirtho committed Dec 14, 2022
1 parent d674b61 commit bd12675
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 32 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ All types of contributions are encouraged and valued. See the [Table of Contents
## Code of Conduct

This project and everyone participating in it is governed by the
[Spotube Code of Conduct](https://github.com/KRTirtho/spotubeblob/master/CODE_OF_CONDUCT.md).
[Spotube Code of Conduct](https://github.com/KRTirtho/spotube/blob/master/CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. Please report unacceptable behavior
to <>.

Expand Down
8 changes: 0 additions & 8 deletions lib/components/root/sidebar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,6 @@ class SidebarFooter extends HookConsumerWidget {
placeholder: ImagePlaceholder.artist,
);

useEffect(() {
if (auth.isLoggedIn && !me.hasData) {
me.setExternalData(ref.read(spotifyProvider));
me.refetch();
}
return;
}, [auth.isLoggedIn, me.hasData]);

return Padding(
padding: const EdgeInsets.all(16).copyWith(left: 0),
child: Row(
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import 'package:spotube/themes/dark_theme.dart';
import 'package:spotube/themes/light_theme.dart';
import 'package:spotube/utils/platform.dart';

final bowl = QueryBowl(refetchOnExternalDataChange: true);
final bowl = QueryBowl();
void main() async {
await Hive.initFlutter();
Hive.registerAdapter(CacheTrackAdapter());
Expand Down
14 changes: 2 additions & 12 deletions lib/pages/lyrics/genius_lyrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ class GeniusLyrics extends HookConsumerWidget {
final breakpoint = useBreakpoints();
final textTheme = Theme.of(context).textTheme;

useEffect(() {
if (playback.track != null) {
geniusLyricsQuery.setExternalData(Tuple2(
playback.track,
ref.read(userPreferencesProvider).geniusAccessToken,
));
geniusLyricsQuery.refetch();
}
return null;
}, [playback.track]);

return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expand Down Expand Up @@ -75,7 +64,8 @@ class GeniusLyrics extends HookConsumerWidget {
padding: const EdgeInsets.all(8.0),
child: Builder(
builder: (context) {
if (geniusLyricsQuery.isLoading) {
if (geniusLyricsQuery.isLoading ||
geniusLyricsQuery.isRefetching) {
return const ShimmerLyrics();
} else if (geniusLyricsQuery.hasError) {
return Text(
Expand Down
1 change: 1 addition & 0 deletions lib/services/queries/lyrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:tuple/tuple.dart';
class LyricsQueries {
final static = QueryJob<String, Tuple2<Track?, String>>(
queryKey: "genius-lyrics-query",
refetchOnExternalDataChange: true,
task: (_, externalData) async {
final currentTrack = externalData.item1;
final geniusAccessToken = externalData.item2;
Expand Down
1 change: 1 addition & 0 deletions lib/services/queries/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class SearchQueries {
final get = InfiniteQueryJob.withVariableKey<List<Page>,
Tuple2<String, SpotifyApi>, int>(
preQueryKey: "search-query",
refetchOnExternalDataChange: true,
initialParam: 0,
enabled: false,
getNextPageParam: (lastPage, lastParam) =>
Expand Down
16 changes: 8 additions & 8 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ packages:
name: connectivity_plus
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.7"
version: "2.3.9"
connectivity_plus_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -387,7 +387,7 @@ packages:
name: connectivity_plus_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.4"
version: "1.2.5"
connectivity_plus_windows:
dependency: transitive
description:
Expand Down Expand Up @@ -489,16 +489,16 @@ packages:
fl_query:
dependency: "direct main"
description:
name: fl_query
url: "https://pub.dartlang.org"
source: hosted
path: "../fl-query/packages/fl_query"
relative: true
source: path
version: "0.3.1"
fl_query_hooks:
dependency: "direct main"
description:
name: fl_query_hooks
url: "https://pub.dartlang.org"
source: hosted
path: "../fl-query/packages/fl_query_hooks"
relative: true
source: path
version: "0.3.1"
fluent_ui:
dependency: "direct main"
Expand Down
6 changes: 4 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ dependencies:
url: https://github.com/KRTirtho/metadata_god.git
ref: 7d195fdde324b382fc12067c56391285807e6233
visibility_detector: ^0.3.3
fl_query: ^0.3.1
fl_query_hooks: ^0.3.1
fl_query:
path: ../fl-query/packages/fl_query
fl_query_hooks:
path: ../fl-query/packages/fl_query_hooks
flutter_inappwebview: ^5.4.3+7
tuple: ^2.0.1
uuid: ^3.0.6
Expand Down

0 comments on commit bd12675

Please sign in to comment.