mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
fix: cached local track is fetched from network, body is not behind AppBar in desktop
This commit is contained in:
parent
8a72f62d14
commit
abf4a5763a
@ -83,6 +83,7 @@ class Shell extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
|
extendBodyBehindAppBar: true,
|
||||||
body: Row(
|
body: Row(
|
||||||
children: [
|
children: [
|
||||||
Sidebar(
|
Sidebar(
|
||||||
|
@ -16,6 +16,7 @@ import 'package:spotube/models/CurrentPlaylist.dart';
|
|||||||
import 'package:spotube/models/Logger.dart';
|
import 'package:spotube/models/Logger.dart';
|
||||||
import 'package:spotube/provider/Playback.dart';
|
import 'package:spotube/provider/Playback.dart';
|
||||||
import 'package:spotube/provider/UserPreferences.dart';
|
import 'package:spotube/provider/UserPreferences.dart';
|
||||||
|
import 'package:spotube/utils/platform.dart';
|
||||||
import 'package:spotube/utils/primitive_utils.dart';
|
import 'package:spotube/utils/primitive_utils.dart';
|
||||||
import 'package:spotube/utils/type_conversion_utils.dart';
|
import 'package:spotube/utils/type_conversion_utils.dart';
|
||||||
|
|
||||||
@ -137,6 +138,7 @@ class UserLocalTracks extends HookConsumerWidget {
|
|||||||
|
|
||||||
useAsyncEffect(
|
useAsyncEffect(
|
||||||
() async {
|
() async {
|
||||||
|
if (!kIsMobile) return;
|
||||||
if (!await Permission.storage.isGranted &&
|
if (!await Permission.storage.isGranted &&
|
||||||
!await Permission.storage.isLimited) {
|
!await Permission.storage.isLimited) {
|
||||||
await Permission.storage.request();
|
await Permission.storage.request();
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:spotify/spotify.dart';
|
import 'package:spotify/spotify.dart';
|
||||||
|
import 'package:spotube/models/SpotubeTrack.dart';
|
||||||
|
|
||||||
extension AlbumJson on AlbumSimple {
|
extension AlbumJson on AlbumSimple {
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
@ -74,8 +75,13 @@ class CurrentPlaylist {
|
|||||||
static CurrentPlaylist fromJson(Map<String, dynamic> map) {
|
static CurrentPlaylist fromJson(Map<String, dynamic> map) {
|
||||||
return CurrentPlaylist(
|
return CurrentPlaylist(
|
||||||
id: map["id"],
|
id: map["id"],
|
||||||
tracks: List.castFrom<dynamic, Track>(
|
tracks: List.castFrom<dynamic, Track>(map["tracks"]
|
||||||
map["tracks"].map((track) => Track.fromJson(track)).toList()),
|
.map(
|
||||||
|
(track) => map["isLocal"] == true
|
||||||
|
? SpotubeTrack.fromJson(track)
|
||||||
|
: Track.fromJson(track),
|
||||||
|
)
|
||||||
|
.toList()),
|
||||||
name: map["name"],
|
name: map["name"],
|
||||||
thumbnail: map["thumbnail"],
|
thumbnail: map["thumbnail"],
|
||||||
isLocal: map["isLocal"],
|
isLocal: map["isLocal"],
|
||||||
@ -108,7 +114,10 @@ class CurrentPlaylist {
|
|||||||
return {
|
return {
|
||||||
"id": id,
|
"id": id,
|
||||||
"name": name,
|
"name": name,
|
||||||
"tracks": tracks.map((track) => track.toJson()).toList(),
|
"tracks": tracks
|
||||||
|
.map((track) =>
|
||||||
|
track is SpotubeTrack ? track.toJson() : track.toJson())
|
||||||
|
.toList(),
|
||||||
"thumbnail": thumbnail,
|
"thumbnail": thumbnail,
|
||||||
"isLocal": isLocal,
|
"isLocal": isLocal,
|
||||||
};
|
};
|
||||||
|
@ -30,9 +30,15 @@ class PlayPauseAction extends Action<PlayPauseIntent> {
|
|||||||
} else if (playback.track != null &&
|
} else if (playback.track != null &&
|
||||||
playback.currentDuration == Duration.zero &&
|
playback.currentDuration == Duration.zero &&
|
||||||
await playback.player.getCurrentPosition() == Duration.zero) {
|
await playback.player.getCurrentPosition() == Duration.zero) {
|
||||||
final track = Track.fromJson(playback.track!.toJson());
|
if (playback.track!.ytUri.startsWith("http")) {
|
||||||
playback.track = null;
|
final track = Track.fromJson(playback.track!.toJson());
|
||||||
await playback.play(track);
|
playback.track = null;
|
||||||
|
await playback.play(track);
|
||||||
|
} else {
|
||||||
|
final track = playback.track;
|
||||||
|
playback.track = null;
|
||||||
|
await playback.play(track!);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
await playback.togglePlayPause();
|
await playback.togglePlayPause();
|
||||||
}
|
}
|
||||||
|
@ -576,8 +576,8 @@ class Playback extends PersistedChangeNotifier {
|
|||||||
track = SpotubeTrack.fromJson(trackMap);
|
track = SpotubeTrack.fromJson(trackMap);
|
||||||
}
|
}
|
||||||
volume = map["volume"] ?? volume;
|
volume = map["volume"] ?? volume;
|
||||||
} catch (e) {
|
} catch (e, stack) {
|
||||||
_logger.e("loadFromLocal", e);
|
_logger.e("loadFromLocal", e, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user