Skip to content

Commit

Permalink
fix(cardwallet): error fix on save image to gallery or show images fu…
Browse files Browse the repository at this point in the history
…llscreen
  • Loading branch information
farfromrefug committed Dec 17, 2024
1 parent 3c6ede1 commit 9feafb4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions app/components/view/CardView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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
}
});
Expand Down
4 changes: 2 additions & 2 deletions app/utils/ui/index.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9feafb4

Please sign in to comment.