mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 16:53:25 +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,
|
media: ScrapeMedia,
|
||||||
headers?: Record<string, string>,
|
headers?: Record<string, string>,
|
||||||
): Promise<Asset | void> => {
|
): 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", {
|
toastController.show("Download started", {
|
||||||
burntOptions: { preset: "none" },
|
burntOptions: { preset: "none" },
|
||||||
native: true,
|
native: true,
|
||||||
@@ -367,11 +377,6 @@ export const DownloadManagerProvider: React.FC<{ children: ReactNode }> = ({
|
|||||||
try {
|
try {
|
||||||
updateDownloadItem(downloadId, { statusText: "Importing" });
|
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);
|
const asset = await MediaLibrary.createAssetAsync(fileUri);
|
||||||
await FileSystem.deleteAsync(fileUri);
|
await FileSystem.deleteAsync(fileUri);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user