mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 14:53:24 +00:00
fix: move perm request to download function
This commit is contained in:
@@ -138,6 +138,16 @@ export const DownloadManagerProvider: React.FC<{ children: ReactNode }> = ({
|
||||
media: ScrapeMedia,
|
||||
headers?: Record<string, string>,
|
||||
): Promise<Asset | void> => {
|
||||
const { status } = await MediaLibrary.requestPermissionsAsync();
|
||||
if (status !== MediaLibrary.PermissionStatus.GRANTED) {
|
||||
toastController.show("Permission denied", {
|
||||
burntOptions: { preset: "error" },
|
||||
native: true,
|
||||
duration: 500,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
toastController.show("Download started", {
|
||||
burntOptions: { preset: "none" },
|
||||
native: true,
|
||||
@@ -367,11 +377,6 @@ export const DownloadManagerProvider: React.FC<{ children: ReactNode }> = ({
|
||||
try {
|
||||
updateDownloadItem(downloadId, { statusText: "Importing" });
|
||||
|
||||
const { status } = await MediaLibrary.requestPermissionsAsync();
|
||||
if (status !== MediaLibrary.PermissionStatus.GRANTED) {
|
||||
throw new Error("MediaLibrary permission not granted");
|
||||
}
|
||||
|
||||
const asset = await MediaLibrary.createAssetAsync(fileUri);
|
||||
await FileSystem.deleteAsync(fileUri);
|
||||
|
||||
|
Reference in New Issue
Block a user