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 { return {
"album": album?.toJson(), "album": album?.toJson(),
"artists": artists?.map((artist) => artist.toJson()).toList(), "artists": artists?.map((artist) => artist.toJson()).toList(),
"availableMarkets": availableMarkets, "availableMarkets": availableMarkets?.map((e) => e.name).toList(),
"discNumber": discNumber, "discNumber": discNumber,
"duration": duration.toString(), "duration": duration.toString(),
"durationMs": durationMs, "durationMs": durationMs,

View File

@ -47,10 +47,15 @@ class SettingsPage extends HookConsumerWidget {
}, []); }, []);
final pickDownloadLocation = useCallback(() async { final pickDownloadLocation = useCallback(() async {
final dirStr = await getDirectoryPath( await openFile();
String? dirStr = await getDirectoryPath(
initialDirectory: preferences.downloadLocation, initialDirectory: preferences.downloadLocation,
); );
if (dirStr == null) return; 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.setDownloadLocation(dirStr);
}, [preferences.downloadLocation]); }, [preferences.downloadLocation]);

View File

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