diff --git a/apps/mobile/app/common/filesystem/download-attachment.js b/apps/mobile/app/common/filesystem/download-attachment.js index 4893c282f..699eb5fe7 100644 --- a/apps/mobile/app/common/filesystem/download-attachment.js +++ b/apps/mobile/app/common/filesystem/download-attachment.js @@ -224,6 +224,13 @@ export default async function downloadAttachment( } try { + useAttachmentStore.getState().setDownloading({ + groupId: options.groupId || attachment.hash, + current: 0, + total: 1, + filename: attachment.filename + }); + await db .fs() .downloadFile( @@ -231,6 +238,15 @@ export default async function downloadAttachment( attachment.hash, attachment.chunkSize ); + + useAttachmentStore.getState().setDownloading({ + groupId: options.groupId || attachment.hash, + current: 1, + total: 1, + filename: attachment.filename, + success: true + }); + if (!(await exists(attachment.hash))) { DatabaseLogger.log("Attachment does not exist after download."); return; @@ -301,6 +317,14 @@ export default async function downloadAttachment( .unlink(RNFetchBlob.fs.dirs.CacheDir + `/${attachment.hash}_dcache`) .catch(console.log); } + + useAttachmentStore.getState().setDownloading({ + groupId: options.groupId || attachment.hash, + current: 0, + total: 0, + filename: attachment.filename, + success: false + }); DatabaseLogger.error(e); useAttachmentStore.getState().remove(attachment.hash); if (options.throwError) { diff --git a/apps/mobile/app/components/attachments/actions.tsx b/apps/mobile/app/components/attachments/actions.tsx index 41aada248..2e860ecd4 100644 --- a/apps/mobile/app/components/attachments/actions.tsx +++ b/apps/mobile/app/components/attachments/actions.tsx @@ -63,9 +63,11 @@ const Actions = ({ attachment, close, setAttachments, - fwdRef + fwdRef, + context }: { attachment: Attachment; + context: string; setAttachments: (attachments?: VirtualizedGrouping) => void; close?: () => void; fwdRef: RefObject; @@ -79,7 +81,6 @@ const Actions = ({ const [loading, setLoading] = useState<{ name?: string; }>({}); - const actions = [ { name: strings.network.download(), @@ -88,7 +89,7 @@ const Actions = ({ await db.fs().cancel(attachment.hash); useAttachmentStore.getState().remove(attachment.hash); } - downloadAttachment(attachment.hash, false); + downloadAttachment(attachment.hash, context === "global"); fwdRef.current?.hide(); }, icon: "download" @@ -375,6 +376,7 @@ Actions.present = ( setAttachments={set} close={close} attachment={attachment} + context={context || "global"} /> ) }); diff --git a/apps/mobile/app/components/attachments/index.tsx b/apps/mobile/app/components/attachments/index.tsx index 4cea36528..1c7ea9926 100644 --- a/apps/mobile/app/components/attachments/index.tsx +++ b/apps/mobile/app/components/attachments/index.tsx @@ -206,7 +206,7 @@ export const AttachmentDialog = ({ errorOnly={currentFilter === "errors"} attachments={attachments} id={index} - context="global" + context={!isSheet ? "global" : "attachments-list"} /> ); diff --git a/apps/mobile/app/components/header/right-menus.tsx b/apps/mobile/app/components/header/right-menus.tsx index ed7c1e5b4..d884555ae 100644 --- a/apps/mobile/app/components/header/right-menus.tsx +++ b/apps/mobile/app/components/header/right-menus.tsx @@ -19,9 +19,8 @@ along with this program. If not, see . import React, { useRef } from "react"; import { Platform, StyleSheet, View } from "react-native"; -//@ts-ignore import { useThemeColors } from "@notesnook/theme"; -import Menu from "react-native-reanimated-material-menu"; +import { Menu } from "react-native-material-menu"; import { notesnook } from "../../../e2e/test.ids"; import { HeaderRightButton, @@ -97,14 +96,16 @@ export const RightMenus = ({ style={{ borderRadius: 5, backgroundColor: contextMenuColors.primary.background, - marginTop: -40 + marginTop: 35 }} onRequestClose={() => { + //@ts-ignore menuRef.current?.hide(); }} anchor={ { + //@ts-ignore menuRef.current?.show(); }} name="dots-vertical" @@ -116,9 +117,10 @@ export const RightMenus = ({ {headerRightButtons.map((item) => (