A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix restoring a note from undo button
ammarahm-ed5d628e57bb50
diff --git a/apps/mobile/src/components/Toast/index.js b/apps/mobile/src/components/Toast/index.jsindex 367cf8367..24111c3dc 100644--- a/apps/mobile/src/components/Toast/index.js+++ b/apps/mobile/src/components/Toast/index.js@@ -147,7 +147,10 @@ export const Toast = ({context = 'global'}) => {return (<Animated.ViewonTouchEnd={() => {- hideToastFunc();+ if (!data.func) {+ hideToastFunc();+ }+}}style={{width: DDS.isTab ? 400 : '100%',@@ -245,6 +248,9 @@ export const Toast = ({context = 'global'}) => {onPress={data.func}title={data.actionText}height={30}+ style={{+ zIndex:10+ }}/>) : null}</Animated.View>diff --git a/apps/mobile/src/utils/functions.js b/apps/mobile/src/utils/functions.jsindex aab9133f4..e44be44b2 100644--- a/apps/mobile/src/utils/functions.js+++ b/apps/mobile/src/utils/functions.js@@ -1,20 +1,20 @@-import { Linking } from 'react-native';-import { InAppBrowser } from 'react-native-inappbrowser-reborn';-import { history } from '.';-import { useMenuStore, useSelectionStore } from '../provider/stores';-import { eSendEvent, ToastEvent } from '../services/EventManager';+import {Linking} from 'react-native';+import {InAppBrowser} from 'react-native-inappbrowser-reborn';+import {history} from '.';+import {useMenuStore, useSelectionStore} from '../provider/stores';+import {eSendEvent, ToastEvent} from '../services/EventManager';import Navigation from '../services/Navigation';-import { db } from './database';-import { eClearEditor } from './Events';+import {db} from './database';+import {eClearEditor} from './Events';-export const deleteItems = async (item) => {+export const deleteItems = async item => {if (item && db.monographs.isPublished(item.id)) {ToastEvent.show({- heading:"Can not delete note",- message:"Unpublish note to delete it",- type:"error",- context:"global"- })+ heading: 'Can not delete note',+ message: 'Unpublish note to delete it',+ type: 'error',+ context: 'global'+ });return;}if (item && item.id && history.selectedItemsList.length === 0) {@@ -22,31 +22,30 @@ export const deleteItems = async (item) => {history.selectedItemsList.push(item);}- let notes = history.selectedItemsList.filter((i) => i.type === 'note');- let notebooks = history.selectedItemsList.filter(- (i) => i.type === 'notebook',- );- let topics = history.selectedItemsList.filter((i) => i.type === 'topic');-+ let notes = history.selectedItemsList.filter(i => i.type === 'note');+ let notebooks = history.selectedItemsList.filter(i => i.type === 'notebook');+ let topics = history.selectedItemsList.filter(i => i.type === 'topic');+if (notes?.length > 0) {+ let ids = notes+ .map(i => {+ if (db.monographs.isPublished(i.id)) {+ ToastEvent.show({+ heading: 'Some notes are published',+ message: 'Unpublish published notes to delete them',+ type: 'error',+ context: 'global'+ });+ return null;+ }+ return i.id;+ })+ .filter(n => n !== null);- let ids = notes.map((i) => {- if (db.monographs.isPublished(i.id)) {- ToastEvent.show({- heading:"Some notes are published",- message:"Unpublish published notes to delete them",- type:"error",- context:"global"- })- return null;- }- return i.id- }).filter(n => n !== null);-await db.notes.delete(...ids);Navigation.setRoutesToUpdate([Navigation.routeNames.Notes,- Navigation.routeNames.NotesPage,+ Navigation.routeNames.NotesPage]);eSendEvent(eClearEditor);}@@ -57,21 +56,21 @@ export const deleteItems = async (item) => {}Navigation.setRoutesToUpdate([Navigation.routeNames.Notebooks,- Navigation.routeNames.Notebook,+ Navigation.routeNames.Notebook]);useMenuStore.getState().setMenuPins();ToastEvent.show({heading: 'Topics deleted',- type: 'success',+ type: 'success'});}if (notebooks?.length > 0) {- let ids = notebooks.map((i) => i.id);+ let ids = notebooks.map(i => i.id);await db.notebooks.delete(...ids);Navigation.setRoutesToUpdate([Navigation.routeNames.Notebooks,- Navigation.routeNames.Notes,+ Navigation.routeNames.Notes]);useMenuStore.getState().setMenuPins();}@@ -85,11 +84,11 @@ export const deleteItems = async (item) => {heading: message,type: 'success',func: async () => {- let trash = db.trash;+ let trash = db.trash.all;let ids = [];for (var i = 0; i < itemsCopy.length; i++) {let it = itemsCopy[i];- let trashItem = trash.all.find((item) => item.itemId === it.id);+ let trashItem = trash.find(item => item.id === it.id);ids.push(trashItem.id);}await db.trash.restore(...ids);@@ -99,13 +98,13 @@ export const deleteItems = async (item) => {Navigation.routeNames.Trash,Navigation.routeNames.NotesPage,Navigation.routeNames.Notebook,- Navigation.routeNames.Trash,+ Navigation.routeNames.Trash]);useMenuStore.getState().setMenuPins();useMenuStore.getState().setColorNotes();ToastEvent.hide();},- actionText: 'Undo',+ actionText: 'Undo'});}history.selectedItemsList = [];@@ -115,8 +114,6 @@ export const deleteItems = async (item) => {useMenuStore.getState().setColorNotes();};--export const openLinkInBrowser = async (link, colors) => {try {const url = link;@@ -138,7 +135,7 @@ export const openLinkInBrowser = async (link, colors) => {secondaryToolbarColor: 'black',enableUrlBarHiding: true,enableDefaultShare: true,- forceCloseOnRedirection: false,+ forceCloseOnRedirection: false});} else Linking.openURL(url);} catch (error) {