Skip to content

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

add delete button

ammarahm-ed22397097ec0a
diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js
index 7f2c7f465..c87df31dd 100644
--- a/apps/mobile/src/components/ActionSheetComponent/index.js
+++ b/apps/mobile/src/components/ActionSheetComponent/index.js
@@ -19,7 +19,7 @@ import {
ToastEvent,
} from '../../services/EventManager';
import PremiumService from '../../services/PremiumService';
-import {toTXT} from '../../utils';
+import {editing, toTXT} from '../../utils';
import {
ACCENT,
COLOR_SCHEME,
@@ -29,9 +29,11 @@ import {
} from '../../utils/Colors';
import {db} from '../../utils/DB';
import {
+ eOnNewTopicAdded,
eOpenLoginDialog,
eOpenMoveNoteDialog,
eShowGetPremium,
+ refreshNotesPage,
} from '../../utils/Events';
import {deleteItems} from '../../utils/functions';
import {MMKV} from '../../utils/mmkv';
@@ -483,6 +485,8 @@ export const ActionSheetComponent = ({
};
const onPressVaultButton = async () => {
+ console.log(editing.actionAfterFirstSave);
+ return;
if (!note.id) return;
if (note.locked) {
close('unlock');
@@ -691,6 +695,44 @@ export const ActionSheetComponent = ({
</PressableButton>
) : null}
+ {editing.actionAfterFirstSave.type === 'topic' &&
+ note.notebooks &&
+ note.notebooks.findIndex(
+ (o) => o.id === editing.actionAfterFirstSave.id,
+ ) ? (
+ <PressableButton
+ accentColor="errorBg"
+ type="accent"
+ customOpacity={0.6}
+ onPress={async () => {
+ await db.notebooks
+ .notebook(editing.actionAfterFirstSave.notebook)
+ .topics.topic(editing.actionAfterFirstSave.id)
+ .delete(note.id);
+
+ eSendEvent(refreshNotesPage);
+ eSendEvent(eOnNewTopicAdded);
+ dispatch({type: Actions.NOTEBOOKS});
+ dispatch({type: Actions.NOTES});
+ setNote(db.notes.note(note.id).data);
+ close();
+ }}
+ testID={notesnook.ids.dialogs.actionsheet.vault}
+ customStyle={{
+ width: '95%',
+ alignSelf: 'center',
+ height: 50,
+ flexDirection: 'row',
+ justifyContent: 'center',
+ alignItems: 'center',
+ marginTop: 10,
+ }}>
+ <Paragraph color="#FF0000" size={SIZE.md}>
+ Remove from Topic
+ </Paragraph>
+ </PressableButton>
+ ) : null}
+
{hasColors && note.id ? (
<ActionSheetColorsSection close={close} item={note} />
) : null}
diff --git a/apps/mobile/src/components/MoveNoteDialog/index.js b/apps/mobile/src/components/MoveNoteDialog/index.js
index 62032a165..3f9a431a3 100644
--- a/apps/mobile/src/components/MoveNoteDialog/index.js
+++ b/apps/mobile/src/components/MoveNoteDialog/index.js
@@ -10,7 +10,7 @@ import {
} from 'react-native';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { notesnook } from '../../../e2e/test.ids';
+import {notesnook} from '../../../e2e/test.ids';
import {useTracked} from '../../provider';
import {Actions} from '../../provider/Actions';
import {DDS} from '../../services/DeviceDetection';
@@ -76,7 +76,6 @@ const MoveNoteDialog = () => {
notebookInput.current?.clear();
notebookInput.current?.blur();
dispatch({type: Actions.NOTEBOOKS});
- dispatch({type: Actions.PINNED});
};
const addNewTopic = async () => {
@@ -85,7 +84,6 @@ const MoveNoteDialog = () => {
}
let res = await db.notebooks.notebook(expanded).topics.add(newTopicTitle);
dispatch({type: Actions.NOTEBOOKS});
- dispatch({type: Actions.PINNED});
topicInput.current?.clear();
topicInput.current?.blur();
newTopicTitle = null;
@@ -346,7 +344,7 @@ const MoveNoteDialog = () => {
noteIds.push(i.id),
);
- let res = await db.notes.move(
+ await db.notes.move(
{
topic: item.title,
id: item.notebookId,
@@ -355,7 +353,7 @@ const MoveNoteDialog = () => {
);
dispatch({type: Actions.CLEAR_SELECTION});
dispatch({type: Actions.NOTEBOOKS});
- dispatch({type: Actions.PINNED});
+ dispatch({type: Actions.NOTES});
close();
let notebookName = db.notebooks.notebook(
item.notebookId,
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js
index 28b6ba7c2..d8f6bdef4 100644
--- a/apps/mobile/src/components/NoteItem/index.js
+++ b/apps/mobile/src/components/NoteItem/index.js
@@ -90,7 +90,7 @@ export default class NoteItem extends React.Component {
width: '92%',
paddingRight: 5,
}}>
- {item.notebooks && item.notebooks.length === 0 && (
+ {item.notebooks && item.notebooks.length > 0 && (
<View
style={{
flexDirection: 'row',
@@ -98,7 +98,7 @@ export default class NoteItem extends React.Component {
<TouchableOpacity
activeOpacity={1}
onPress={() => {
- let notebook = db.notebooks.notebook(item.notebook.id).data;
+ let notebook = db.notebooks.notebook(item.notebooks[0].id).data;
updateEvent({
type: Actions.HEADER_TEXT_STATE,
state: {
@@ -110,7 +110,7 @@ export default class NoteItem extends React.Component {
state: false,
});
Navigation.navigate('Notebook', {
- notebook: db.notebooks.notebook(item.notebook.id).data,
+ notebook: db.notebooks.notebook(item.notebooks[0].id).data,
title: notebook.title,
root: true,
});
@@ -132,7 +132,7 @@ export default class NoteItem extends React.Component {
<Heading
size={SIZE.xs}
color={item.color ? COLORS_NOTE[item.color] : colors.accent}>
- {db.notebooks.notebook(item.notebooks[0].id).title}
+ {db.notebooks.notebook(item.notebooks[0].id).title + " "} {item.notebooks.length > 1? "& " + (item.notebooks.length - 1) + " others" : ""}
</Heading>
</TouchableOpacity>
</View>
diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.js
index 105be3b8d..f6749e12d 100644
--- a/apps/mobile/src/views/Notes/index.js
+++ b/apps/mobile/src/views/Notes/index.js
@@ -49,7 +49,7 @@ export const Notes = ({route, navigation}) => {
} else {
editing.actionAfterFirstSave = {
type: 'topic',
- id: params.title,
+ id: params.id,
notebook: params.notebookId,
};
}
@@ -62,16 +62,17 @@ export const Notes = ({route, navigation}) => {
}
if (route.params.menu) {
navigation.setOptions({
- animationEnabled:false,
- gestureEnabled:false
- })
+ animationEnabled: false,
+ gestureEnabled: false,
+ });
} else {
navigation.setOptions({
- animationEnabled:true,
- gestureEnabled:true
- })
+ animationEnabled: true,
+ gestureEnabled: true,
+ });
}
let allNotes = [];
+ console.log(params.type);
if (params.type === 'tag') {
allNotes = db.notes.tagged(params.tag.id);
} else if (params.type === 'color') {
@@ -81,7 +82,8 @@ export const Notes = ({route, navigation}) => {
.notebook(params.notebookId)
.topics.topic(params.title).all;
}
- if (allNotes && allNotes.length > 0) {
+
+ if (allNotes) {
setNotes([...allNotes]);
}
setActionAfterFirstSave();
@@ -190,9 +192,10 @@ export const Notes = ({route, navigation}) => {
init();
}}
headerProps={{
- heading: params.type === 'tag'
- ? '#' + params.title
- : params.title.slice(0, 1).toUpperCase() + params.title.slice(1),
+ heading:
+ params.type === 'tag'
+ ? '#' + params.title
+ : params.title.slice(0, 1).toUpperCase() + params.title.slice(1),
}}
focused={() => navigation.isFocused()}
RenderItem={NoteItemWrapper}