mobile: add file size limits

This commit is contained in:
ammarahm-ed
2023-06-03 23:21:10 +05:00
parent ac39ca8a11
commit f30c066305
5 changed files with 14 additions and 2 deletions

View File

@@ -35,8 +35,7 @@ import PremiumService from "../../../services/premium";
import { eCloseSheet } from "../../../utils/events";
import { editorController, editorState } from "./utils";
import { isImage } from "@notesnook/core/utils/filename";
const FILE_SIZE_LIMIT = 500 * 1024 * 1024;
const IMAGE_SIZE_LIMIT = 50 * 1024 * 1024;
import { FILE_SIZE_LIMIT, IMAGE_SIZE_LIMIT } from "../../../utils/constants";
const showEncryptionSheet = (file) => {
presentSheet({

View File

@@ -21,6 +21,8 @@ import { Platform } from "react-native";
import { Monographs } from "../screens/notes/monographs";
export const IOS_APPGROUPID = "group.org.streetwriters.notesnook";
export const FILE_SIZE_LIMIT = 500 * 1024 * 1024;
export const IMAGE_SIZE_LIMIT = 50 * 1024 * 1024;
export const STORE_LINK =
Platform.OS === "ios"

View File

@@ -63,5 +63,7 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>appGroupId</key>
<string>group.org.streetwriters.notesnook</string>
</dict>
</plist>

View File

@@ -151,5 +151,7 @@
</dict>
</dict>
</array>
<key>appGroupId</key>
<string>group.org.streetwriters.notesnook</string>
</dict>
</plist>

View File

@@ -52,6 +52,7 @@ import { Search } from "./search";
import { initDatabase, useShareStore } from "./store";
import { isImage } from "@notesnook/core/utils/filename";
import { NoteBundle } from "../app/utils/note-bundle";
import { FILE_SIZE_LIMIT, IMAGE_SIZE_LIMIT } from "../app/utils/constants";
const getLinkPreview = (url) => {
return getPreviewData(url, 5000);
@@ -280,6 +281,12 @@ const ShareView = ({ quicknote = false }) => {
} else {
const user = await db.user.getUser();
if (user && user.subscription.type !== 0) {
if (
(isImage(item.type) && item.size > IMAGE_SIZE_LIMIT) ||
(!isImage(item.type) && item.size > FILE_SIZE_LIMIT)
)
continue;
setRawFiles((files) => {
const index = files.findIndex((file) => file.name === item.name);
if (index === -1) {