mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix: spotify friends and user profile icon (mobile) showing when not authenticated #1410
This commit is contained in:
parent
7e07c2e198
commit
9bccbc93c6
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -24,5 +24,6 @@
|
|||||||
"explorer.fileNesting.patterns": {
|
"explorer.fileNesting.patterns": {
|
||||||
"pubspec.yaml": "pubspec.lock,analysis_options.yaml,.packages,.flutter-plugins,.flutter-plugins-dependencies,flutter_launcher_icons*.yaml,flutter_native_splash*.yaml",
|
"pubspec.yaml": "pubspec.lock,analysis_options.yaml,.packages,.flutter-plugins,.flutter-plugins-dependencies,flutter_launcher_icons*.yaml,flutter_native_splash*.yaml",
|
||||||
"README.md": "LICENSE,CODE_OF_CONDUCT.md,CONTRIBUTING.md,SECURITY.md,CONTRIBUTION.md,CHANGELOG.md,PRIVACY_POLICY.md",
|
"README.md": "LICENSE,CODE_OF_CONDUCT.md,CONTRIBUTING.md,SECURITY.md,CONTRIBUTION.md,CHANGELOG.md,PRIVACY_POLICY.md",
|
||||||
|
"*.dart": "${capture}.g.dart,${capture}.freezed.dart",
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +1,14 @@
|
|||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:skeletonizer/skeletonizer.dart';
|
import 'package:skeletonizer/skeletonizer.dart';
|
||||||
import 'package:spotube/collections/fake.dart';
|
import 'package:spotube/collections/fake.dart';
|
||||||
import 'package:spotube/components/home/sections/friends/friend_item.dart';
|
import 'package:spotube/components/home/sections/friends/friend_item.dart';
|
||||||
import 'package:spotube/hooks/utils/use_breakpoint_value.dart';
|
import 'package:spotube/hooks/utils/use_breakpoint_value.dart';
|
||||||
import 'package:spotube/models/spotify_friends.dart';
|
import 'package:spotube/models/spotify_friends.dart';
|
||||||
|
import 'package:spotube/provider/authentication_provider.dart';
|
||||||
import 'package:spotube/provider/spotify/spotify.dart';
|
import 'package:spotube/provider/spotify/spotify.dart';
|
||||||
|
|
||||||
class HomePageFriendsSection extends HookConsumerWidget {
|
class HomePageFriendsSection extends HookConsumerWidget {
|
||||||
@ -14,6 +16,7 @@ class HomePageFriendsSection extends HookConsumerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, ref) {
|
Widget build(BuildContext context, ref) {
|
||||||
|
final auth = ref.watch(authenticationProvider);
|
||||||
final friendsQuery = ref.watch(friendsProvider);
|
final friendsQuery = ref.watch(friendsProvider);
|
||||||
final friends =
|
final friends =
|
||||||
friendsQuery.asData?.value.friends ?? FakeData.friends.friends;
|
friendsQuery.asData?.value.friends ?? FakeData.friends.friends;
|
||||||
@ -27,32 +30,36 @@ class HomePageFriendsSection extends HookConsumerWidget {
|
|||||||
xxl: 7,
|
xxl: 7,
|
||||||
);
|
);
|
||||||
|
|
||||||
final friendGroup = friends.fold<List<List<SpotifyFriendActivity>>>(
|
final friendGroup = useMemoized(
|
||||||
[],
|
() => friends.fold<List<List<SpotifyFriendActivity>>>(
|
||||||
(previousValue, element) {
|
[],
|
||||||
if (previousValue.isEmpty) {
|
(previousValue, element) {
|
||||||
|
if (previousValue.isEmpty) {
|
||||||
|
return [
|
||||||
|
[element]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
final lastGroup = previousValue.last;
|
||||||
|
if (lastGroup.length < groupCount) {
|
||||||
|
return [
|
||||||
|
...previousValue.sublist(0, previousValue.length - 1),
|
||||||
|
[...lastGroup, element]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
...previousValue,
|
||||||
[element]
|
[element]
|
||||||
];
|
];
|
||||||
}
|
},
|
||||||
|
),
|
||||||
final lastGroup = previousValue.last;
|
[friends, groupCount],
|
||||||
if (lastGroup.length < groupCount) {
|
|
||||||
return [
|
|
||||||
...previousValue.sublist(0, previousValue.length - 1),
|
|
||||||
[...lastGroup, element]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
...previousValue,
|
|
||||||
[element]
|
|
||||||
];
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (friendsQuery.isLoading ||
|
if (friendsQuery.isLoading ||
|
||||||
friendsQuery.asData?.value.friends.isEmpty == true) {
|
friendsQuery.asData?.value.friends.isEmpty == true ||
|
||||||
|
auth == null) {
|
||||||
return const SliverToBoxAdapter(
|
return const SliverToBoxAdapter(
|
||||||
child: SizedBox.shrink(),
|
child: SizedBox.shrink(),
|
||||||
);
|
);
|
||||||
|
@ -14,6 +14,7 @@ import 'package:spotube/components/shared/image/universal_image.dart';
|
|||||||
import 'package:spotube/components/shared/page_window_title_bar.dart';
|
import 'package:spotube/components/shared/page_window_title_bar.dart';
|
||||||
import 'package:spotube/extensions/constrains.dart';
|
import 'package:spotube/extensions/constrains.dart';
|
||||||
import 'package:spotube/extensions/image.dart';
|
import 'package:spotube/extensions/image.dart';
|
||||||
|
import 'package:spotube/provider/authentication_provider.dart';
|
||||||
import 'package:spotube/provider/spotify/spotify.dart';
|
import 'package:spotube/provider/spotify/spotify.dart';
|
||||||
import 'package:spotube/utils/platform.dart';
|
import 'package:spotube/utils/platform.dart';
|
||||||
import 'package:spotube/utils/service_utils.dart';
|
import 'package:spotube/utils/service_utils.dart';
|
||||||
@ -41,9 +42,14 @@ class HomePage extends HookConsumerWidget {
|
|||||||
const ConnectDeviceButton(),
|
const ConnectDeviceButton(),
|
||||||
const Gap(10),
|
const Gap(10),
|
||||||
Consumer(builder: (context, ref, _) {
|
Consumer(builder: (context, ref, _) {
|
||||||
|
final auth = ref.watch(authenticationProvider);
|
||||||
final me = ref.watch(meProvider);
|
final me = ref.watch(meProvider);
|
||||||
final meData = me.asData?.value;
|
final meData = me.asData?.value;
|
||||||
|
|
||||||
|
if (auth == null) {
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
|
|
||||||
return IconButton(
|
return IconButton(
|
||||||
icon: CircleAvatar(
|
icon: CircleAvatar(
|
||||||
backgroundImage: UniversalImage.imageProvider(
|
backgroundImage: UniversalImage.imageProvider(
|
||||||
|
Loading…
Reference in New Issue
Block a user