fix(android ): file_selector getDirectoryPath returns unusable content urls #720

This commit is contained in:
Kingkor Roy Tirtho 2023-09-26 22:34:21 +06:00
parent a7e102ffc7
commit b3cf639ee2
3 changed files with 10 additions and 4 deletions

View File

@ -7,7 +7,7 @@ extension TrackJson on Track {
return {
"album": album?.toJson(),
"artists": artists?.map((artist) => artist.toJson()).toList(),
"availableMarkets": availableMarkets,
"availableMarkets": availableMarkets?.map((e) => e.name).toList(),
"discNumber": discNumber,
"duration": duration.toString(),
"durationMs": durationMs,

View File

@ -47,10 +47,15 @@ class SettingsPage extends HookConsumerWidget {
}, []);
final pickDownloadLocation = useCallback(() async {
final dirStr = await getDirectoryPath(
await openFile();
String? dirStr = await getDirectoryPath(
initialDirectory: preferences.downloadLocation,
);
if (dirStr == null) return;
if (DesktopTools.platform.isAndroid && dirStr.startsWith("content://")) {
dirStr =
"/storage/emulated/0/${Uri.decodeFull(dirStr).split("primary:").last}";
}
preferences.setDownloadLocation(dirStr);
}, [preferences.downloadLocation]);

View File

@ -119,8 +119,9 @@ class PlaylistQueries {
return useSpotifyQuery<bool, dynamic>(
"playlist-is-followed/$playlistId/$userId",
(spotify) async {
final result = await spotify.playlists.followedBy(playlistId, [userId]);
return result.first;
final result =
await spotify.playlists.followedByUsers(playlistId, [userId]);
return result[userId] ?? false;
},
ref: ref,
);