Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: fix file size check shows error but continues uploading the file

Ammar Ahmed87bddf003797
diff --git a/apps/mobile/app/common/filesystem/upload.ts b/apps/mobile/app/common/filesystem/upload.ts
index b5fb45a8b..0e2a484a2 100644
--- a/apps/mobile/app/common/filesystem/upload.ts
+++ b/apps/mobile/app/common/filesystem/upload.ts
@@ -35,6 +35,8 @@ import Upload from "@ammarahmed/react-native-upload";
import { CloudUploader } from "react-native-nitro-cloud-uploader";
import { useUserStore } from "../../stores/use-user-store";
import { sleep } from "../../utils/time";
+import { isFeatureAvailable } from "@notesnook/common";
+import { strings } from "@notesnook/intl";
// Upload constants
const CHUNK_SIZE = 10 * 1024 * 1024; // 10 MB
@@ -199,6 +201,20 @@ export async function uploadFile(
const remoteFileSize = await getUploadedFileSize(filename);
if (remoteFileSize === FileSizeResult.Error) return false;
+ const featureResult = await isFeatureAvailable(
+ "fileSize",
+ fileInfo.size || 0
+ );
+
+ if (!featureResult.isAllowed) {
+ ToastManager.show({
+ heading: strings.fileTooLarge(),
+ message: featureResult.error,
+ type: "error"
+ });
+ return false;
+ }
+
if (
remoteFileSize > FileSizeResult.Empty &&
remoteFileSize === fileInfo.size
diff --git a/apps/mobile/app/screens/editor/tiptap/picker.ts b/apps/mobile/app/screens/editor/tiptap/picker.ts
index a6d095fb4..7aea6e8e0 100644
--- a/apps/mobile/app/screens/editor/tiptap/picker.ts
+++ b/apps/mobile/app/screens/editor/tiptap/picker.ts
@@ -90,6 +90,7 @@ const file = async (fileOptions: PickerOptions) => {
message: featureResult.error,
type: "error"
});
+ return;
}
if (fileCopyUri.status === "error") {
@@ -272,6 +273,7 @@ const handleImageResponse = async (
message: featureResult.error,
type: "error"
});
+ return;
}
const b64 = `data:${image.mime};base64, ` + image.data;