Skip to content

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

fix topic deleting

ammarahm-ede8e7c9b1de92
diff --git a/apps/mobile/src/components/Dialog/index.js b/apps/mobile/src/components/Dialog/index.js
index 955d06465..d21f1b7db 100644
--- a/apps/mobile/src/components/Dialog/index.js
+++ b/apps/mobile/src/components/Dialog/index.js
@@ -14,7 +14,12 @@ import NavigationService from '../../services/NavigationService';
import {getElevation, ToastEvent, editing, history} from '../../utils/utils';
import {dialogActions, updateEvent} from '../DialogManager';
import {eSendEvent} from '../../services/eventManager';
-import {eCloseFullscreenEditor, eOnLoadNote} from '../../services/events';
+import {
+ eCloseFullscreenEditor,
+ eOnLoadNote,
+ eOnNewTopicAdded,
+} from '../../services/events';
+import {exitEditorAnimation} from '../../utils/animations';
export class Dialog extends Component {
constructor(props) {
@@ -30,10 +35,11 @@ export class Dialog extends Component {
switch (template.action) {
case dialogActions.ACTION_DELETE: {
- if (item.id && history.selectedItemsList.length === 0) {
+ if (item.dateCreated && history.selectedItemsList.length === 0) {
history.selectedItemsList = [];
history.selectedItemsList.push(item);
}
+ console.log(history.selectedItemsList.length, 'BREAK', item);
history.selectedItemsList.forEach(async i => {
if (i.type === 'note') {
await db.notes.delete(i.id);
@@ -41,6 +47,8 @@ export class Dialog extends Component {
updateEvent({type: i.type});
} else if (i.type === 'topic') {
await db.notebooks.notebook(i.notebookId).topics.delete(i.title);
+
+ eSendEvent(eOnNewTopicAdded);
updateEvent({type: 'notebook'});
ToastEvent.show('Topics deleted', 'error', 3000);
@@ -58,11 +66,11 @@ export class Dialog extends Component {
visible: false,
});
if (editing.currentlyEditing) {
+ eSendEvent(eOnLoadNote, {type: 'new'});
if (DDS.isTab) {
eSendEvent(eCloseFullscreenEditor);
- eSendEvent(eOnLoadNote, {type: 'new'});
} else {
- NavigationService.goBack();
+ exitEditorAnimation();
}
}
break;
diff --git a/apps/mobile/src/utils/animations.js b/apps/mobile/src/utils/animations.js
index 2b3ad2671..73e7fdea9 100644
--- a/apps/mobile/src/utils/animations.js
+++ b/apps/mobile/src/utils/animations.js
@@ -6,6 +6,7 @@ const {color, Value, timing} = Animated;
export const EditorPosition = new Value(Dimensions.get('window').width * 1.5);
export function openEditorAnimation() {
+ editing.currentlyEditing = true;
let openConfigH = {
duration: 300,
toValue: 0,
@@ -15,6 +16,7 @@ export function openEditorAnimation() {
}
export function exitEditorAnimation() {
+ editing.currentlyEditing = false;
let openConfigH = {
duration: 300,
toValue: Dimensions.get('window').width * 1.5,
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index a5835d321..a251b52e3 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -135,7 +135,6 @@ const Editor = ({navigation, noMenu}) => {
};
const _onMessage = evt => {
- console.log(evt.nativeEvent.data);
if (evt.nativeEvent.data === 'loaded') {
} else if (
evt.nativeEvent.data !== '' &&
@@ -354,8 +353,6 @@ const Editor = ({navigation, noMenu}) => {
};
useEffect(() => {
- editing.currentlyEditing = true;
-
let handleBack;
if (!noMenu && DDS.isTab) {
handleBack = BackHandler.addEventListener('hardwareBackPress', () => {
@@ -376,7 +373,6 @@ const Editor = ({navigation, noMenu}) => {
}
return () => {
- editing.currentlyEditing = false;
if (handleBack) {
handleBack.remove();
handleBack = null;