Skip to content

Commit

Permalink
fix: genre and sidebar user logo not loading
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Jan 6, 2023
1 parent d495709 commit 710f172
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 20 deletions.
18 changes: 16 additions & 2 deletions lib/components/root/sidebar.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:badges/badges.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:fl_query_hooks/fl_query_hooks.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
Expand Down Expand Up @@ -194,9 +193,10 @@ class SidebarFooter extends HookConsumerWidget {
width: 256,
child: HookBuilder(
builder: (context) {
var spotify = ref.watch(spotifyProvider);
final me = useQuery(
job: Queries.user.me,
externalData: ref.watch(spotifyProvider),
externalData: spotify,
);
final data = me.data;

Expand All @@ -206,6 +206,20 @@ class SidebarFooter extends HookConsumerWidget {
placeholder: ImagePlaceholder.artist,
);

// TODO: Remove below code after fl-query ^0.4.0
/// Temporary fix before fl-query 0.4.0
final auth = ref.watch(authProvider);

useEffect(() {
if (auth.isLoggedIn && me.hasError) {
me.setExternalData(spotify);
me.refetch();
}
return null;
}, [auth, me.hasError]);

/// ===================================
return Padding(
padding: const EdgeInsets.all(16).copyWith(left: 0),
child: Row(
Expand Down
17 changes: 17 additions & 0 deletions lib/pages/genre/genres.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:spotube/components/genre/category_card.dart';
import 'package:spotube/components/shared/shimmers/shimmer_categories.dart';
import 'package:spotube/components/shared/page_window_title_bar.dart';
import 'package:spotube/components/shared/waypoint.dart';
import 'package:spotube/provider/auth_provider.dart';
import 'package:spotube/provider/spotify_provider.dart';

import 'package:spotube/provider/user_preferences_provider.dart';
Expand Down Expand Up @@ -47,6 +48,22 @@ class GenrePage extends HookConsumerWidget {

final isMounted = useIsMounted();

/// Temporary fix before fl-query 0.4.0
final auth = ref.watch(authProvider);

useEffect(() {
if (auth.isLoggedIn && categoriesQuery.hasError) {
categoriesQuery.setExternalData({
"spotify": spotify,
"recommendationMarket": recommendationMarket,
});
categoriesQuery.refetchPages();
}
return null;
}, [auth, categoriesQuery.hasError]);

/// ===================================
return PlatformScaffold(
appBar: kIsDesktop ? PageWindowTitleBar() : null,
body: Waypoint(
Expand Down
4 changes: 3 additions & 1 deletion lib/services/queries/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class SearchQueries {
initialParam: 0,
enabled: false,
getNextPageParam: (lastPage, lastParam) =>
(lastPage.first.items?.length ?? 0) < 10 ? null : lastParam + 10,
lastPage.isNotEmpty && (lastPage.first.items?.length ?? 0) < 10
? null
: lastParam + 10,
getPreviousPageParam: (lastPage, lastParam) => lastParam - 10,
task: (queryKey, pageParam, variables) {
final queryString = variables.item1;
Expand Down
22 changes: 10 additions & 12 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -130,54 +130,52 @@ packages:
audioplayers:
dependency: "direct main"
description:
path: "packages/audioplayers"
ref: "3ee12cd0361c0fc2f3d0303c504732d12fa8e49a"
resolved-ref: "3ee12cd0361c0fc2f3d0303c504732d12fa8e49a"
url: "https://github.com/bluefireteam/audioplayers.git"
source: git
version: "1.0.1"
name: audioplayers
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
audioplayers_android:
dependency: transitive
description:
name: audioplayers_android
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.1.3"
audioplayers_darwin:
dependency: transitive
description:
name: audioplayers_darwin
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.0.4"
audioplayers_linux:
dependency: transitive
description:
name: audioplayers_linux
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.0.2"
audioplayers_platform_interface:
dependency: transitive
description:
name: audioplayers_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "2.1.0"
audioplayers_web:
dependency: transitive
description:
name: audioplayers_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "2.1.0"
audioplayers_windows:
dependency: transitive
description:
name: audioplayers_windows
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.1.1"
auto_size_text:
dependency: "direct main"
description:
Expand Down
6 changes: 1 addition & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ dependencies:
hive: ^2.2.3
hive_flutter: ^1.1.0
dbus: ^0.7.3
audioplayers:
git:
url: https://github.com/bluefireteam/audioplayers.git
ref: 3ee12cd0361c0fc2f3d0303c504732d12fa8e49a
path: packages/audioplayers/
audioplayers: ^1.2.0
introduction_screen: ^3.0.2
audio_session: ^0.1.10
file_picker: ^5.2.2
Expand Down

0 comments on commit 710f172

Please sign in to comment.