Skip to content

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

mobile: skip showing loading overlay for relatively smaller notes

ammarahm-ed77ab2d7740b8
diff --git a/apps/mobile/app/screens/editor/loading.js b/apps/mobile/app/screens/editor/loading.js
index 296636b90..59cdba4ad 100644
--- a/apps/mobile/app/screens/editor/loading.js
+++ b/apps/mobile/app/screens/editor/loading.js
@@ -28,12 +28,12 @@ import { Button } from "../../components/ui/button";
import { IconButton } from "../../components/ui/icon-button";
import Paragraph from "../../components/ui/typography/paragraph";
import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";
-import { DDS } from "../../services/device-detection";
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent
} from "../../services/event-manager";
+import { useSettingStore } from "../../stores/use-setting-store";
import { useThemeStore } from "../../stores/use-theme-store";
import { eClearEditor } from "../../utils/events";
import { SIZE } from "../../utils/size";
@@ -43,6 +43,8 @@ const EditorOverlay = ({ editorId = "", editor }) => {
const [error, setError] = useState(false);
const opacity = useSharedValue(1);
const translateValue = useSharedValue(6000);
+ const deviceMode = useSettingStore((state) => state.deviceMode);
+ const isTablet = deviceMode !== "mobile";
const insets = useGlobalSafeAreaInsets();
const isDefaultEditor = editorId === "";
const timers = useRef({
@@ -153,7 +155,7 @@ const EditorOverlay = ({ editorId = "", editor }) => {
paddingRight: 12
}}
>
- {DDS.isTablet() ? (
+ {isTablet ? (
<View />
) : (
<IconButton
@@ -197,7 +199,9 @@ const EditorOverlay = ({ editorId = "", editor }) => {
alignItems: "center",
flexDirection: "row",
paddingHorizontal: 10,
- marginTop: 10
+ marginTop: 5,
+ borderWidth: 1,
+ borderColor: colors.border
}}
>
<Paragraph color={colors.icon} size={13}>
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
index 00d2c8fcf..6f34f0820 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
@@ -152,7 +152,7 @@ export const useEditor = (
);
const reset = useCallback(
- async (resetState = true) => {
+ async (resetState = true, resetContent = true) => {
currentNote.current?.id && db.fs.cancel(currentNote.current.id);
currentNote.current = null;
loadedImages.current = {};
@@ -161,10 +161,10 @@ export const useEditor = (
sessionHistoryId.current = undefined;
saveCount.current = 0;
useEditorStore.getState().setReadonly(false);
- postMessage(EditorEvents.title, "");
+ resetContent && postMessage(EditorEvents.title, "");
lastContentChangeTime.current = 0;
- await commands.clearContent();
- await commands.clearTags();
+ resetContent && (await commands.clearContent());
+ resetContent && (await commands.clearTags());
if (resetState) {
isDefaultEditor &&
useEditorStore.getState().setCurrentlyEditingNote(null);
@@ -369,9 +369,16 @@ export const useEditor = (
} else {
if (!item.forced && currentNote.current?.id === item.id) return;
isDefaultEditor && editorState.setCurrentlyEditingNote(item.id);
- overlay(true, item);
- currentNote.current && (await reset(false));
+ currentNote.current && (await reset(false, false));
await loadContent(item as NoteType);
+ if (
+ !currentContent.current?.data ||
+ currentContent.current?.data.length < 50000
+ ) {
+ overlay(false);
+ } else {
+ overlay(true);
+ }
lastContentChangeTime.current = item.dateEdited;
const nextSessionId = makeSessionId(item as NoteType);
sessionHistoryId.current = Date.now();