Compare commits

...

4 Commits

Author SHA1 Message Date
ammarahm-ed
ee359770ce mobile: always load notes on init 2023-04-26 08:53:27 +05:00
ammarahm-ed
9d2b445078 mobile: ensure that overlay gets hidden when entering foreground 2023-04-26 08:21:10 +05:00
ammarahm-ed
43421c5478 mobile: only show app lock for main activity 2023-04-26 08:20:36 +05:00
ammarahm-ed
4b60e8bb9e mobile: reload editor if rendered view lost 2023-04-25 19:52:04 +05:00
7 changed files with 29 additions and 10 deletions

View File

@@ -37,6 +37,7 @@ import { useNoteStore } from "../../stores/use-notes-store";
import { useSettingStore } from "../../stores/use-setting-store";
import { useThemeStore } from "../../stores/use-theme-store";
import { useUserStore } from "../../stores/use-user-store";
import { AndroidModule } from "../../utils";
import { eOpenAnnouncementDialog } from "../../utils/events";
import { getGithubVersion } from "../../utils/github-version";
import { SIZE } from "../../utils/size";
@@ -192,6 +193,11 @@ const Launcher = React.memo(
const onUnlockBiometrics = useCallback(async () => {
if (!(await BiometricService.isBiometryAvailable())) return;
if (Platform.OS === "android") {
const activityName = await AndroidModule.getActivityName();
if (activityName !== "MainActivity") return;
}
let verified = await BiometricService.validateUser(
"Unlock to access your notes",
""

View File

@@ -571,8 +571,8 @@ export const useAppEvents = () => {
if (notesAddedFromIntent || shareExtensionOpened) {
let id = useEditorStore.getState().currentEditingNote;
let note = id && db.notes.note(id).data;
eSendEvent("loadingNote", note);
eSendEvent("webview_reset");
setTimeout(() => eSendEvent("loadingNote", note), 1);
MMKV.removeItem("shareExtensionOpened");
}
} catch (e) {

View File

@@ -580,22 +580,21 @@ export const useEditor = (
const onReady = useCallback(async () => {
if (!(await isEditorLoaded(editorRef, sessionIdRef.current))) {
overlay(true);
setLoading(true);
eSendEvent("webview_reset");
} else {
isDefaultEditor && restoreEditorState();
}
}, [overlay, isDefaultEditor, restoreEditorState]);
}, [isDefaultEditor, restoreEditorState]);
useEffect(() => {
state.current.saveCount = 0;
async () => {
(async () => {
await commands.setSessionId(sessionIdRef.current);
if (sessionIdRef.current) {
if (!state.current?.ready) return;
await onReady();
}
};
})();
}, [sessionId, loading, commands, onReady]);
const onLoad = useCallback(async () => {
@@ -636,6 +635,7 @@ export const useEditor = (
saveContent,
onContentChanged,
editorId: editorId,
markImageLoaded
markImageLoaded,
overlay
};
};

View File

@@ -51,6 +51,7 @@ export const EditorWrapper = ({ width }) => {
if (editorState().movedAway) return;
if (state === "active") {
editorController.current.onReady();
editorController.current.overlay(false);
}
};

View File

@@ -86,8 +86,9 @@ async function getNextMonthlyReminderDate(
}
async function initDatabase(notes = true) {
if (db.isInitialized) return;
await db.initCollections();
if (!db.isInitialized) {
await db.initCollections();
}
if (notes) {
await db.notes?.init();
}

View File

@@ -4,6 +4,7 @@ package com.streetwriters.notesnook;
import android.graphics.Color;
import android.view.WindowManager;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactApplicationContext;
@@ -36,6 +37,16 @@ public class RCTNNativeModule extends ReactContextBaseJavaModule {
}
}
@ReactMethod
public void getActivityName(Promise promise) {
try {
promise.resolve(getCurrentActivity().getClass().getSimpleName());
} catch (Exception e) {
promise.resolve(null);
}
}
@ReactMethod
public void setSecureMode(final boolean mode) {

View File

@@ -31,8 +31,8 @@ export async function initDatabase() {
if (!db.isInitialized) {
// Only load collections in database.
await db.initCollections();
await db.notes.init();
}
await db.notes.init();
}
const StorageKeys = {