From 9feafb442f8114bdce26a9469a86d44538ed867f Mon Sep 17 00:00:00 2001 From: farfromrefug Date: Tue, 17 Dec 2024 15:18:25 +0100 Subject: [PATCH] fix(cardwallet): error fix on save image to gallery or show images fullscreen --- app/components/view/CardView.svelte | 20 +++++++++++--------- app/utils/ui/index.common.ts | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/components/view/CardView.svelte b/app/components/view/CardView.svelte index 25bac5a4..caff3c64 100644 --- a/app/components/view/CardView.svelte +++ b/app/components/view/CardView.svelte @@ -253,10 +253,10 @@ currentQRCodeIndex = event.object.selectedIndex; } function getSelectedPages() { - const selected = []; + const selected: { page: OCRPage; document: OCRDocument }[] = []; items.forEach((d, index) => { if (d.selected) { - selected.push(d.page); + selected.push({ page: d.page, document }); } }); return selected; @@ -272,7 +272,7 @@ } async function showPDFPopover(event) { try { - const pages = nbSelected > 0 ? getSelectedPages() : document.pages; + const pages = nbSelected > 0 ? getSelectedPages() : document.pages.map((p) => ({ page: p, document })); await showPDFPopoverMenu(pages, document, event.object); } catch (err) { showError(err); @@ -421,12 +421,14 @@ page: component, // transition: __ANDROID__ ? SharedTransition.custom(new PageTransition(300, undefined, 10), {}) : undefined, props: { - images: getSelectedPages().map((page) => ({ - // sharedTransitionTag: `document_${doc.id}_${page.id}`, - name: page.name || document.name, - image: page.imagePath, - ...page - })), + images: getSelectedPages() + .filter((p) => p.page.imagePath) + .map((p) => ({ + // sharedTransitionTag: `document_${doc.id}_${page.id}`, + name: document.name, + image: p.page.imagePath, + ...p + })), startPageIndex: 0 } }); diff --git a/app/utils/ui/index.common.ts b/app/utils/ui/index.common.ts index 0677aaa7..e297e587 100644 --- a/app/utils/ui/index.common.ts +++ b/app/utils/ui/index.common.ts @@ -726,8 +726,8 @@ export async function showPDFPopoverMenu(pages: { page: OCRPage; document: OCRDo } async function exportImages(pages: { page: OCRPage; document: OCRDocument }[], exportDirectory: string, toGallery = false) { - const sortedPages = pages.sort((a, b) => a.page.createdDate - b.page.createdDate); - const imagePaths = sortedPages.map((page) => page.page.imagePath); + const sortedPages = pages.filter((p) => p.page).sort((a, b) => a.page.createdDate - b.page.createdDate); + const imagePaths = sortedPages.map((p) => p.page.imagePath); const imageExportSettings = getImageExportSettings(); const canSetName = !toGallery && imagePaths.length === 1;