From df58a6cfc44416e3d32a03bc2cacaa76eb8f3efd Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Fri, 19 May 2023 14:53:49 +0500 Subject: [PATCH] mobile: fix recheck attachments --- .../app/components/attachments/index.js | 48 +++++++++++++------ 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/apps/mobile/app/components/attachments/index.js b/apps/mobile/app/components/attachments/index.js index 5ce300ec7..8f14b66a7 100644 --- a/apps/mobile/app/components/attachments/index.js +++ b/apps/mobile/app/components/attachments/index.js @@ -18,7 +18,7 @@ along with this program. If not, see . */ import React, { useRef, useState } from "react"; -import { View } from "react-native"; +import { ActivityIndicator, View } from "react-native"; import { FlatList } from "react-native-actions-sheet"; import Icon from "react-native-vector-icons/MaterialCommunityIcons"; import { db } from "../../common/database"; @@ -71,14 +71,21 @@ export const AttachmentDialog = ({ note }) => { const onCheck = async () => { setLoading(true); + const checkedAttachments = []; for (let attachment of attachments) { let result = await filesystem.checkAttachment(attachment.metadata.hash); if (result.failed) { - db.attachments.markAsFailed(attachment.metadata.hash, result.failed); + await db.attachments.markAsFailed( + attachment.metadata.hash, + result.failed + ); } else { - db.attachments.markAsFailed(attachment.id, null); + await db.attachments.markAsFailed(attachment.id, null); } - setAttachments([...db.attachments.all]); + checkedAttachments.push( + db.attachments.attachment(attachment.metadata.hash) + ); + setAttachments([...checkedAttachments]); } setLoading(false); }; @@ -106,17 +113,28 @@ export const AttachmentDialog = ({ note }) => { flexDirection: "row" }} > - + {loading ? ( + + ) : ( + + )}