mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-09 08:47:31 +00:00
chore: trying to fix memory leak
This commit is contained in:
parent
5ac971fea1
commit
7bc9520bab
@ -62,7 +62,7 @@ class PlaylistCard extends HookConsumerWidget {
|
||||
|
||||
List<Track> fetchedTracks = await queryBowl.fetchQuery(
|
||||
"playlist-tracks/${playlist.id}",
|
||||
() => useQueries.playlist.tracksOf(playlist.id!, spotify),
|
||||
() => useQueries.playlist.tracksOf(playlist.id!, spotify, ref),
|
||||
) ??
|
||||
[];
|
||||
|
||||
@ -83,7 +83,7 @@ class PlaylistCard extends HookConsumerWidget {
|
||||
if (isPlaylistPlaying) return;
|
||||
List<Track> fetchedTracks = await queryBowl.fetchQuery(
|
||||
"playlist-tracks/${playlist.id}",
|
||||
() => useQueries.playlist.tracksOf(playlist.id!, spotify),
|
||||
() => useQueries.playlist.tracksOf(playlist.id!, spotify, ref),
|
||||
) ??
|
||||
[];
|
||||
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:args/args.dart';
|
||||
import 'package:catcher/catcher.dart';
|
||||
import 'package:device_preview/device_preview.dart';
|
||||
import 'package:fl_query/fl_query.dart';
|
||||
import 'package:fl_query_devtools/fl_query_devtools.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@ -209,7 +207,11 @@ class SpotubeState extends ConsumerState<Spotube> {
|
||||
builder: (context, child) {
|
||||
return DevicePreview.appBuilder(
|
||||
context,
|
||||
DragToResizeArea(child: child!),
|
||||
DragToResizeArea(
|
||||
child: FlQueryDevtools(
|
||||
child: child!,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
themeMode: themeMode,
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:catcher/catcher.dart';
|
||||
import 'package:fl_query/fl_query.dart';
|
||||
import 'package:fl_query_hooks/fl_query_hooks.dart';
|
||||
@ -10,6 +12,7 @@ import 'package:spotube/extensions/track.dart';
|
||||
import 'package:spotube/hooks/use_spotify_infinite_query.dart';
|
||||
import 'package:spotube/hooks/use_spotify_query.dart';
|
||||
import 'package:spotube/pages/library/playlist_generate/playlist_generate.dart';
|
||||
import 'package:spotube/provider/authentication_provider.dart';
|
||||
import 'package:spotube/provider/custom_spotify_endpoint_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences_provider.dart';
|
||||
|
||||
@ -138,19 +141,26 @@ class PlaylistQueries {
|
||||
(lastPageData.items?.length ?? 0) < 10 || lastPageData.isLast
|
||||
? null
|
||||
: lastPage + 1,
|
||||
retryConfig: RetryConfig.withConstantDefaults(
|
||||
maxRetries: 1,
|
||||
retryDelay: const Duration(seconds: 5),
|
||||
),
|
||||
ref: ref,
|
||||
);
|
||||
}
|
||||
|
||||
Future<List<Track>> tracksOf(String playlistId, SpotifyApi spotify) {
|
||||
Future<List<Track>> tracksOf(
|
||||
String playlistId,
|
||||
SpotifyApi spotify,
|
||||
WidgetRef ref,
|
||||
) {
|
||||
if (playlistId == "user-liked-tracks") {
|
||||
return spotify.tracks.me.saved.all().then(
|
||||
return spotify.tracks.me.saved
|
||||
.all()
|
||||
.then(
|
||||
(tracks) => tracks.map((e) => e.track!).toList(),
|
||||
);
|
||||
)
|
||||
.catchError((e) {
|
||||
final isLoggedIn = ref.read(AuthenticationNotifier.provider) != null;
|
||||
if (e is SocketException && isLoggedIn) return <Track>[];
|
||||
throw e;
|
||||
});
|
||||
}
|
||||
return spotify.playlists.getTracksByPlaylistId(playlistId).all().then(
|
||||
(value) => value.toList(),
|
||||
@ -163,7 +173,7 @@ class PlaylistQueries {
|
||||
) {
|
||||
return useSpotifyQuery<List<Track>, dynamic>(
|
||||
"playlist-tracks/$playlistId",
|
||||
(spotify) => tracksOf(playlistId, spotify),
|
||||
(spotify) => tracksOf(playlistId, spotify, ref),
|
||||
jsonConfig: playlistId == "user-liked-tracks"
|
||||
? JsonConfig(
|
||||
toJson: (tracks) => <String, dynamic>{
|
||||
@ -176,6 +186,10 @@ class PlaylistQueries {
|
||||
.toList(),
|
||||
)
|
||||
: null,
|
||||
retryConfig: RetryConfig.withConstantDefaults(
|
||||
maxRetries: 1,
|
||||
retryDelay: const Duration(seconds: 5),
|
||||
),
|
||||
ref: ref,
|
||||
);
|
||||
}
|
||||
|
||||
21
pubspec.lock
21
pubspec.lock
@ -517,23 +517,26 @@ packages:
|
||||
fl_query:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "../fl-query/packages/fl_query"
|
||||
relative: true
|
||||
source: path
|
||||
name: fl_query
|
||||
sha256: "64f482fc09eb1166adca232f68772b2b11c616d88bce3208b2753c940ebc9f71"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0-alpha.3"
|
||||
fl_query_devtools:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "../fl-query/packages/fl_query_devtools"
|
||||
relative: true
|
||||
source: path
|
||||
name: fl_query_devtools
|
||||
sha256: f46148364d7fc49fb02ab2d3b2c280e6652edd3984e9fdf14c1b49d4d8473907
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.0-alpha.1"
|
||||
fl_query_hooks:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "../fl-query/packages/fl_query_hooks"
|
||||
relative: true
|
||||
source: path
|
||||
name: fl_query_hooks
|
||||
sha256: b0ffc81fb047cbcedd9766776f9c72b95382730ce173226f0695c3f45774b0bc
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0-alpha.3"
|
||||
fluentui_system_icons:
|
||||
dependency: "direct main"
|
||||
|
||||
11
pubspec.yaml
11
pubspec.yaml
@ -34,12 +34,9 @@ dependencies:
|
||||
duration: ^3.0.12
|
||||
envied: ^0.3.0
|
||||
file_picker: ^5.2.2
|
||||
fl_query:
|
||||
path: ../fl-query/packages/fl_query
|
||||
fl_query_hooks:
|
||||
path: ../fl-query/packages/fl_query_hooks
|
||||
fl_query_devtools:
|
||||
path: ../fl-query/packages/fl_query_devtools
|
||||
fl_query: ^1.0.0-alpha.3
|
||||
fl_query_hooks: ^1.0.0-alpha.3
|
||||
fl_query_devtools: ^0.1.0-alpha.1
|
||||
fluentui_system_icons: ^1.1.189
|
||||
flutter:
|
||||
sdk: flutter
|
||||
@ -123,8 +120,6 @@ dev_dependencies:
|
||||
dependency_overrides:
|
||||
http: ^1.1.0
|
||||
flutter_hooks: ^0.20.0
|
||||
fl_query:
|
||||
path: ../fl-query/packages/fl_query
|
||||
|
||||
flutter:
|
||||
generate: true
|
||||
|
||||
Loading…
Reference in New Issue
Block a user