From 5cd9d48befb114d74659c1ffc752da020e91e6eb Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Wed, 15 Jan 2025 12:22:30 +0500 Subject: [PATCH] mobile: fix selecting image from gallery when applock is on --- apps/mobile/app/components/ui/sheet/index.js | 5 ++++- apps/mobile/app/screens/editor/tiptap/picker.ts | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/mobile/app/components/ui/sheet/index.js b/apps/mobile/app/components/ui/sheet/index.js index 21d55d736..b1d33dedb 100644 --- a/apps/mobile/app/components/ui/sheet/index.js +++ b/apps/mobile/app/components/ui/sheet/index.js @@ -100,7 +100,10 @@ const SheetWrapper = ({ useEffect(() => { if (useUserStore.getState().disableAppLockRequests) return; - if (SettingsService.canLockAppInBackground()) { + if ( + SettingsService.canLockAppInBackground() && + SettingsService.shouldLockAppOnEnterForeground() + ) { if (appState === "background") { const ref = fwdRef || localRef; ref?.current?.hide(); diff --git a/apps/mobile/app/screens/editor/tiptap/picker.ts b/apps/mobile/app/screens/editor/tiptap/picker.ts index 952d84133..ef0434041 100644 --- a/apps/mobile/app/screens/editor/tiptap/picker.ts +++ b/apps/mobile/app/screens/editor/tiptap/picker.ts @@ -43,6 +43,8 @@ import { eCloseSheet } from "../../../utils/events"; import { useTabStore } from "./use-tab-store"; import { editorController, editorState } from "./utils"; import { strings } from "@notesnook/intl"; +import { useUserStore } from "../../../stores/use-user-store"; +import { sleep } from "../../../utils/time"; const showEncryptionSheet = (file: DocumentPickerResponse) => { presentSheet({ @@ -241,6 +243,13 @@ const gallery = async (options: PickerOptions) => { const pick = async (options: PickerOptions) => { if (!PremiumService.get()) { const user = await db.user.getUser(); + if (!user) { + ToastManager.show({ + heading: strings.loginRequired(), + type: "error" + }); + return; + } if (editorState().isFocused) { editorState().isFocused = true; } @@ -251,6 +260,7 @@ const pick = async (options: PickerOptions) => { } return; } + useUserStore.getState().setDisableAppLockRequests(true); if (options?.type.startsWith("image") || options?.type === "camera") { if (options.type.startsWith("image")) { gallery(options); @@ -267,6 +277,7 @@ const handleImageResponse = async ( options: PickerOptions ) => { const result = await AttachImage.present(response, options.context); + if (!result) return; const compress = result.compress;