mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00
fix: local tracks getting fetched on first load
This commit is contained in:
parent
ea45c4f42a
commit
73c012c71a
@ -95,7 +95,7 @@ final localTracksProvider = FutureProvider<List<LocalTrack>>((ref) async {
|
|||||||
return {"metadata": metadata, "file": f, "art": imageFile.path};
|
return {"metadata": metadata, "file": f, "art": imageFile.path};
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
if (e is FfiException) {
|
if (e is FfiException) {
|
||||||
return {};
|
return {"file": f};
|
||||||
}
|
}
|
||||||
Catcher.reportCheckedError(e, stack);
|
Catcher.reportCheckedError(e, stack);
|
||||||
return {};
|
return {};
|
||||||
|
@ -22,7 +22,7 @@ import 'package:spotube/utils/type_conversion_utils.dart';
|
|||||||
/// Things to implement:
|
/// Things to implement:
|
||||||
/// * [x] Sponsor-Block skip
|
/// * [x] Sponsor-Block skip
|
||||||
/// * [x] Prefetch next track as [SpotubeTrack] on 80% of current track
|
/// * [x] Prefetch next track as [SpotubeTrack] on 80% of current track
|
||||||
/// * [ ] Mixed Queue containing both [SpotubeTrack] and [LocalTrack]
|
/// * [x] Mixed Queue containing both [SpotubeTrack] and [LocalTrack]
|
||||||
/// * [ ] Modification of the Queue
|
/// * [ ] Modification of the Queue
|
||||||
/// * [x] Add track at the end
|
/// * [x] Add track at the end
|
||||||
/// * [x] Add track at the beginning
|
/// * [x] Add track at the beginning
|
||||||
@ -218,29 +218,37 @@ class ProxyPlaylistNotifier extends PersistedStateNotifier<ProxyPlaylist>
|
|||||||
bool autoPlay = false,
|
bool autoPlay = false,
|
||||||
}) async {
|
}) async {
|
||||||
tracks = blacklist.filter(tracks).toList() as List<Track>;
|
tracks = blacklist.filter(tracks).toList() as List<Track>;
|
||||||
final addableTrack = await SpotubeTrack.fetchFromTrack(
|
final indexTrack = tracks.elementAtOrNull(initialIndex) ?? tracks.first;
|
||||||
tracks.elementAtOrNull(initialIndex) ?? tracks.first,
|
|
||||||
preferences,
|
|
||||||
pipedClient,
|
|
||||||
);
|
|
||||||
|
|
||||||
state = state.copyWith(
|
if (indexTrack is LocalTrack) {
|
||||||
tracks: mergeTracks([addableTrack], tracks),
|
state = state.copyWith(
|
||||||
active: initialIndex,
|
tracks: tracks.toSet(),
|
||||||
);
|
active: initialIndex,
|
||||||
|
);
|
||||||
|
await notificationService.addTrack(indexTrack);
|
||||||
|
} else {
|
||||||
|
final addableTrack = await SpotubeTrack.fetchFromTrack(
|
||||||
|
tracks.elementAtOrNull(initialIndex) ?? tracks.first,
|
||||||
|
preferences,
|
||||||
|
pipedClient,
|
||||||
|
);
|
||||||
|
|
||||||
await notificationService.addTrack(addableTrack);
|
state = state.copyWith(
|
||||||
|
tracks: mergeTracks([addableTrack], tracks),
|
||||||
|
active: initialIndex,
|
||||||
|
);
|
||||||
|
await notificationService.addTrack(addableTrack);
|
||||||
|
await storeTrack(
|
||||||
|
tracks.elementAt(initialIndex),
|
||||||
|
addableTrack,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await audioPlayer.openPlaylist(
|
await audioPlayer.openPlaylist(
|
||||||
state.tracks.map(makeAppropriateSource).toList(),
|
state.tracks.map(makeAppropriateSource).toList(),
|
||||||
initialIndex: initialIndex,
|
initialIndex: initialIndex,
|
||||||
autoPlay: autoPlay,
|
autoPlay: autoPlay,
|
||||||
);
|
);
|
||||||
|
|
||||||
await storeTrack(
|
|
||||||
tracks.elementAt(initialIndex),
|
|
||||||
addableTrack,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> jumpTo(int index) async {
|
Future<void> jumpTo(int index) async {
|
||||||
|
@ -323,7 +323,7 @@ class _MprisMediaPlayer2Player extends DBusObject {
|
|||||||
"xesam:url": DBusString(
|
"xesam:url": DBusString(
|
||||||
playlist.activeTrack is SpotubeTrack
|
playlist.activeTrack is SpotubeTrack
|
||||||
? (playlist.activeTrack as SpotubeTrack).ytUri
|
? (playlist.activeTrack as SpotubeTrack).ytUri
|
||||||
: playlist.activeTrack!.previewUrl!,
|
: playlist.activeTrack!.previewUrl ?? "",
|
||||||
),
|
),
|
||||||
"xesam:genre": const DBusString("Unknown"),
|
"xesam:genre": const DBusString("Unknown"),
|
||||||
}),
|
}),
|
||||||
|
Loading…
Reference in New Issue
Block a user