From 15684b4ea1dbbebf6e66bdcecd400be3266e9b95 Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Sun, 15 Nov 2020 12:17:05 +0500 Subject: [PATCH] fix permission not asked on export --- apps/mobile/src/services/Exporter.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/apps/mobile/src/services/Exporter.js b/apps/mobile/src/services/Exporter.js index b916cb556..606c8bee0 100644 --- a/apps/mobile/src/services/Exporter.js +++ b/apps/mobile/src/services/Exporter.js @@ -37,6 +37,13 @@ async function saveToPDF(note) { async function saveToMarkdown(note) { let path = await Storage.checkAndCreateDir('/exported/Markdown/'); + if (Platform.OS === 'android') { + let hasPermission = await Storage.requestPermission(); + if (!hasPermission) { + ToastEvent.show('Failed to get storage permission'); + return null; + } + } let markdown = await db.notes.note(note.id).export('md'); path = path + note.title + '.md'; @@ -51,6 +58,13 @@ async function saveToMarkdown(note) { async function saveToText(note) { let path = await Storage.checkAndCreateDir('/exported/Text/'); + if (Platform.OS === 'android') { + let hasPermission = await Storage.requestPermission(); + if (!hasPermission) { + ToastEvent.show('Failed to get storage permission'); + return null; + } + } let markdown = await db.notes.note(note.id).export('txt'); path = path + note.title + '.txt'; await RNFetchBlob.fs.writeFile(path, markdown, 'utf8'); @@ -64,6 +78,13 @@ async function saveToText(note) { async function saveToHTML(note) { let path = await Storage.checkAndCreateDir('/exported/Html/'); + if (Platform.OS === 'android') { + let hasPermission = await Storage.requestPermission(); + if (!hasPermission) { + ToastEvent.show('Failed to get storage permission'); + return null; + } + } let markdown = await db.notes.note(note.id).export('html'); path = path + note.title + '.html'; await RNFetchBlob.fs.writeFile(path, markdown, 'utf8');