Skip to content

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

mobile: fix selecting image from gallery when applock is on

Ammar Ahmed0cad09855133
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;