A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: use `checkFeature`
Abdullah Atta97f8f1e3c34d
diff --git a/apps/web/src/components/editor/picker.ts b/apps/web/src/components/editor/picker.tsindex 18ebb60c8..51e1a0959 100644--- a/apps/web/src/components/editor/picker.ts+++ b/apps/web/src/components/editor/picker.ts@@ -34,7 +34,7 @@ import {import Config from "../../utils/config";import { compressImage, FileWithURI } from "../../utils/image-compressor";import { ImageCompressionOptions } from "../../stores/setting-store";-import { isFeatureAvailable } from "@notesnook/common";+import { checkFeature } from "../../common";export async function insertAttachments(type = "*/*") {const files = await showFilePicker({@@ -129,8 +129,7 @@ async function pickFile(options?: AddAttachmentOptions): Promise<Attachment | undefined> {try {- const feature = await isFeatureAvailable("fileSize", file.size);- if (!feature.isAllowed) throw new Error(feature.error);+ if (!(await checkFeature("fileSize", file.size))) return;const hash = await addAttachment(file, options);return {@@ -155,8 +154,7 @@ async function pickImage(options?: AddAttachmentOptions): Promise<Attachment | undefined> {try {- const feature = await isFeatureAvailable("fileSize", file.size);- if (!feature.isAllowed) throw new Error(feature.error);+ if (!(await checkFeature("fileSize", file.size))) return;const hash = await addAttachment(file, options);const dimensions = await getImageDimensions(file);diff --git a/apps/web/src/dialogs/image-picker-dialog.tsx b/apps/web/src/dialogs/image-picker-dialog.tsxindex 17fbf7c18..c4530f30b 100644--- a/apps/web/src/dialogs/image-picker-dialog.tsx+++ b/apps/web/src/dialogs/image-picker-dialog.tsx@@ -21,11 +21,11 @@ import { useEffect, useState } from "react";import Dialog from "../components/dialog";import { ScrollContainer } from "@notesnook/ui";import { Flex, Image, Label, Text } from "@theme-ui/components";-import { formatBytes, isFeatureAvailable } from "@notesnook/common";+import { formatBytes } from "@notesnook/common";import { compressImage, FileWithURI } from "../utils/image-compressor";import { BaseDialogProps, DialogManager } from "../common/dialog-manager";import { strings } from "@notesnook/intl";-import { showFeatureNotAllowedToast } from "../common/toasts";+import { checkFeature } from "../common";export type ImagePickerDialogProps = BaseDialogProps<false | File[]> & {images: File[];@@ -132,8 +132,8 @@ export const ImagePickerDialog = DialogManager.register(defaultChecked={compress}checked={compress}onChange={async () => {- const result = await isFeatureAvailable("fullQualityImages");- if (!result.isAllowed) return showFeatureNotAllowedToast(result);+ if (!(await checkFeature("fullQualityImages", { type: "toast" })))+ return;setCompress((s) => !s);}}/>