Skip to content

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

fix properties error when no note

ammarahm-ede449435e51da
diff --git a/apps/mobile/src/components/Properties/index.js b/apps/mobile/src/components/Properties/index.js
index 1953da963..55867ab65 100644
--- a/apps/mobile/src/components/Properties/index.js
+++ b/apps/mobile/src/components/Properties/index.js
@@ -20,12 +20,13 @@ export const Properties = ({close = () => {}, item, buttons = [], getRef}) => {
const [state, dispatch] = useTracked();
const {colors} = state;
- const alias =
- item.type === 'tag'
+ const alias = item
+ ? item.type === 'tag'
? db.tags.alias(item.id)
: item.type === 'color'
? db.colors.alias(item.id)
- : item.title;
+ : item.title
+ : null;
const onScrollEnd = () => {
getRef().current?.handleChildScrollEnd();
@@ -113,8 +114,10 @@ export const Properties = ({close = () => {}, item, buttons = [], getRef}) => {
};
Properties.present = (item, buttons = []) => {
- let type = item.type;
+ if (!item) return;
+ let type = item?.type;
let props = [item];
+
switch (type) {
case 'trash':
props.push(['PermDelete', 'Restore']);
diff --git a/apps/mobile/src/views/Editor/EditorHeader.js b/apps/mobile/src/views/Editor/EditorHeader.js
index 316711238..f2907d8c3 100644
--- a/apps/mobile/src/views/Editor/EditorHeader.js
+++ b/apps/mobile/src/views/Editor/EditorHeader.js
@@ -1,5 +1,5 @@
-import {EV, EVENTS} from 'notes-core/common';
-import React, {useEffect, useRef} from 'react';
+import { EV, EVENTS } from 'notes-core/common';
+import React, { useEffect, useRef } from 'react';
import {
BackHandler,
InteractionManager,
@@ -8,18 +8,17 @@ import {
Vibration,
View
} from 'react-native';
-import {useSafeAreaInsets} from 'react-native-safe-area-context';
-import {notesnook} from '../../../e2e/test.ids';
-import {ActionIcon} from '../../components/ActionIcon';
-import {ActionSheetEvent} from '../../components/DialogManager/recievers';
+import { useSafeAreaInsets } from 'react-native-safe-area-context';
+import { notesnook } from '../../../e2e/test.ids';
+import { ActionIcon } from '../../components/ActionIcon';
import { Properties } from '../../components/Properties';
-import {useTracked} from '../../provider';
+import { useTracked } from '../../provider';
import {
useEditorStore,
useSettingStore,
useUserStore
} from '../../provider/stores';
-import {DDS} from '../../services/DeviceDetection';
+import { DDS } from '../../services/DeviceDetection';
import {
eSendEvent,
eSubscribeEvent,
@@ -27,8 +26,8 @@ import {
ToastEvent
} from '../../services/EventManager';
import Navigation from '../../services/Navigation';
-import {editing, SUBSCRIPTION_STATUS} from '../../utils';
-import {db} from '../../utils/database';
+import { editing, SUBSCRIPTION_STATUS } from '../../utils';
+import { db } from '../../utils/database';
import {
eClearEditor,
eCloseFullscreenEditor,
@@ -38,24 +37,21 @@ import {
eOpenPremiumDialog,
eOpenPublishNoteDialog
} from '../../utils/Events';
-import {tabBarRef} from '../../utils/Refs';
-import {sleep} from '../../utils/TimeUtils';
-import {EditorTitle} from './EditorTitle';
+import { tabBarRef } from '../../utils/Refs';
+import { EditorTitle } from './EditorTitle';
import {
clearEditor,
- clearTimer,
- EditorWebView,
- getNote,
+ clearTimer, getNote,
loadNote,
setColors,
startClosingSession
} from './Functions';
-import {ProgressCircle} from './ProgressCircle';
-import tiny, {safeKeyboardDismiss} from './tiny/tiny';
-import {endSearch} from './tiny/toolbar/commands';
-import {toolbarRef} from './tiny/toolbar/constants';
+import { ProgressCircle } from './ProgressCircle';
+import tiny, { safeKeyboardDismiss } from './tiny/tiny';
+import { endSearch } from './tiny/toolbar/commands';
+import { toolbarRef } from './tiny/toolbar/constants';
import picker from './tiny/toolbar/picker';
-import {useEditorTags} from './useEditorTags';
+import { useEditorTags } from './useEditorTags';
const EditorHeader = () => {
const [state] = useTracked();
@@ -165,10 +161,22 @@ const EditorHeader = () => {
const showActionsheet = async () => {
let note = getNote() && db.notes.note(getNote().id).data;
+
+ if (!note) {
+ ToastEvent.show({
+ heading: 'Start writing to create a new note',
+ type: 'success',
+ context: 'global'
+ });
+
+ return;
+ }
+
if (editing.isFocused || editing.keyboardState) {
safeKeyboardDismiss();
editing.isFocused = true;
}
+
Properties.present(note, ['Dark Mode']);
};