From aae1df10f2d3e66dc984fde17bde4e7fc6dc380f Mon Sep 17 00:00:00 2001 From: Dale de Silva Date: Fri, 10 Feb 2023 08:19:17 +1100 Subject: [PATCH] Refined the accepted files --- src/logic/import-logic.ts | 19 ++++++++++++++----- src/modals/import-modal/import-modal.ts | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/logic/import-logic.ts b/src/logic/import-logic.ts index 135383d..df820d9 100644 --- a/src/logic/import-logic.ts +++ b/src/logic/import-logic.ts @@ -123,13 +123,22 @@ export async function importFiles(plugin: KeepPlugin, files: Array) { if(file.type === 'application/json') { if(!noteFolder) noteFolder = await getOrCreateFolder(settings.folderNames.notes, vault); result = await importJson(vault, noteFolder, file, settings); - } else { - // image/png - // video/3gpp - // image/jpeg - // * + } else if( file.type === 'video/3gpp' || + file.type === 'audio/amr' || + file.type === 'image/png' || + file.type === 'image/jpeg' || + file.type === 'image/jpg' || + file.type === 'image/webp' || + file.type === 'image/gif' + ) { if(!assetFolder) assetFolder = await getOrCreateFolder(settings.folderNames.attachments, vault); result = await importBinaryFile(vault, assetFolder, file); + } else { + result = { + keepFilename: file.name, + outcome: ImportOutcomeType.CreationError, + details: `This file wasn't imported because this plugin doesn\'t support importing ${file.type} files.`, + } } // Populate output log on error diff --git a/src/modals/import-modal/import-modal.ts b/src/modals/import-modal/import-modal.ts index 6f32578..cc65ee5 100644 --- a/src/modals/import-modal/import-modal.ts +++ b/src/modals/import-modal/import-modal.ts @@ -26,7 +26,7 @@ export class StartImportModal extends Modal { titleEl.setText('Import Google Keep backup'); - contentEl.createEl('p', {text: 'Here you can upload a set of jsons output from a Google Keep backup.'}); + contentEl.createEl('p', {text: 'Here you can upload a set of jsons output from a Google Keep backup (Google Takeout).'}); contentEl.createEl('p', {text: 'Upload each json one at a time or all together. You should also upload any attachments in the backup as well such as png\'s jpgs, etc.'}); contentEl.createEl('p', {text: 'If you import attachments or jsons separately and close this dialog, they will will automatically link together once their counterparts are imported later provided you haven\'t changed the names of attachments or modified the markdown embeds in the notes.'});