Skip to content

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

bug fixes

ammarahm-ed096cc89694a5
diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js
index 9c9ac14a0..15d428feb 100644
--- a/apps/mobile/src/components/ActionSheetComponent/index.js
+++ b/apps/mobile/src/components/ActionSheetComponent/index.js
@@ -81,22 +81,11 @@ export const ActionSheetComponent = ({
if (tag.includes(' ')) {
tag = tag.replace(' ', '_');
}
- let oldProps = {...note};
-
- if (oldProps.tags.includes(tag)) {
- return;
- } else {
- oldProps.tags.push(tag);
- }
-
tagsInputRef.setNativeProps({
text: '',
});
- await db.addNote({
- dateCreated: note.dateCreated,
- tags: oldProps.tags,
- });
+ await db.addTag(note.dateCreated, tag);
setNote({...db.getNote(note.dateCreated)});
tagToAdd = '';
};
@@ -114,13 +103,12 @@ export const ActionSheetComponent = ({
let tagInputValue = note.tags[note.tags.length - 1];
let oldProps = {...note};
if (oldProps.tags.length === 0) return;
+ //oldProps.tags.splice(oldProps.tags.length - 1);
+ await db.removeTag(
+ note.dateCreated,
+ oldProps.tags[oldProps.tags.length - 1],
+ );
- oldProps.tags.splice(oldProps.tags.length - 1);
-
- await db.addNote({
- dateCreated: note.dateCreated,
- tags: oldProps.tags,
- });
setNote({...db.getNote(note.dateCreated)});
tagsInputRef.setNativeProps({
@@ -262,9 +250,13 @@ export const ActionSheetComponent = ({
icon: 'tag',
func: async () => {
if (!note.dateCreated) return;
- await db.pinItem(note.type, note.dateCreated);
- localRefresh(item.type);
+ if (note.type === 'note') {
+ await db.pinNote(note.dateCreated);
+ } else {
+ await db.pinNotebook(note.dateCreated);
+ }
dispatch({type: ACTIONS.PINNED});
+ localRefresh(item.type);
},
close: false,
check: true,
@@ -275,9 +267,13 @@ export const ActionSheetComponent = ({
icon: 'star',
func: async () => {
if (!note.dateCreated) return;
- await db.favoriteItem(note.type, note.dateCreated);
- localRefresh(item.type);
+ if (note.type === 'note') {
+ await db.favoriteNotes([note.dateCreated]);
+ } else {
+ await db.favoriteNotebooks([note.dateCreated]);
+ }
dispatch({type: ACTIONS.FAVORITES});
+ localRefresh(item.type);
},
close: false,
check: true,
@@ -484,7 +480,10 @@ export const ActionSheetComponent = ({
return (
<View
onLayout={() => {
- localRefresh(item.type, true);
+ if (!item.dateDeleted) {
+ localRefresh(item.type, true);
+ }
+ console.log(note.dateCreated, 'here');
}}
style={{
paddingBottom: 15,
diff --git a/apps/mobile/src/components/AddNotebookDialog/index.js b/apps/mobile/src/components/AddNotebookDialog/index.js
index 817759b9d..762a7d673 100644
--- a/apps/mobile/src/components/AddNotebookDialog/index.js
+++ b/apps/mobile/src/components/AddNotebookDialog/index.js
@@ -31,7 +31,6 @@ export class AddNotebookDialog extends React.Component {
};
this.title = null;
this.description = null;
-
this.listRef;
this.prevItem = null;
this.prevIndex = null;
@@ -123,6 +122,7 @@ export class AddNotebookDialog extends React.Component {
};
onSubmit = () => {
+ let {topics} = this.state;
if (
!this.currentInputValue ||
this.currentInputValue === '' ||
diff --git a/apps/mobile/src/components/Dialog/index.js b/apps/mobile/src/components/Dialog/index.js
index 6427818bb..22131af99 100644
--- a/apps/mobile/src/components/Dialog/index.js
+++ b/apps/mobile/src/components/Dialog/index.js
@@ -74,10 +74,20 @@ export class Dialog extends Component {
visible: false,
});
}
+ case dialogActions.ACTION_TRASH: {
+ db.restoreItem(item.dateCreated);
+ updateEvent({type: ACTIONS.TRASH});
+ this.hide();
+ }
}
};
_onClose = () => {
+ let {template, item} = this.props;
+ if (dialogActions.ACTION_TRASH === template.action) {
+ // delete item forever.
+ console.log('deleted forever');
+ }
this.setState({
visible: false,
});
@@ -174,7 +184,7 @@ export class Dialog extends Component {
}}>
<TouchableOpacity
activeOpacity={opacity}
- onPress={this._onPress}
+ onPress={this._onClose}
style={{
paddingVertical: pv,
paddingHorizontal: ph,
@@ -182,23 +192,20 @@ export class Dialog extends Component {
width: '48%',
justifyContent: 'center',
alignItems: 'center',
- borderColor: colors.accent,
- backgroundColor: colors.accent,
- borderWidth: 1,
+ backgroundColor: colors.nav,
}}>
<Text
style={{
fontFamily: WEIGHT.medium,
- color: 'white',
+ color: colors.icon,
fontSize: SIZE.sm,
}}>
- {positiveText}
+ {negativeText}
</Text>
</TouchableOpacity>
-
<TouchableOpacity
activeOpacity={opacity}
- onPress={this._onClose}
+ onPress={this._onPress}
style={{
paddingVertical: pv,
paddingHorizontal: ph,
@@ -206,15 +213,17 @@ export class Dialog extends Component {
width: '48%',
justifyContent: 'center',
alignItems: 'center',
- backgroundColor: colors.nav,
+ borderColor: colors.accent,
+ backgroundColor: colors.accent,
+ borderWidth: 1,
}}>
<Text
style={{
fontFamily: WEIGHT.medium,
- color: colors.icon,
+ color: 'white',
fontSize: SIZE.sm,
}}>
- {negativeText}
+ {positiveText}
</Text>
</TouchableOpacity>
</View>
diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.js
index 62cb5e9da..879160dba 100644
--- a/apps/mobile/src/components/DialogManager/index.js
+++ b/apps/mobile/src/components/DialogManager/index.js
@@ -35,6 +35,7 @@ export const dialogActions = {
ACTION_EXIT: 512,
ACTION_EMPTY_TRASH: 513,
ACTION_EXIT_FULLSCREEN: 514,
+ ACTION_TRASH: 515,
};
export const ActionSheetEvent = (
@@ -101,6 +102,17 @@ export const TEMPLATE_DELETE = type => {
};
};
+export const TEMPLATE_TRASH = type => {
+ return {
+ title: `Delete ${type}`,
+ paragraph: `Restore or delete ${type} forever`,
+ positiveText: 'Restore',
+ negativeText: 'Delete',
+ action: dialogActions.ACTION_TRASH,
+ icon: 'trash',
+ };
+};
+
export const TEMPLATE_EXIT_FULLSCREEN = () => {
return {
title: `Exit fullscreen editor?`,
diff --git a/apps/mobile/src/components/MoveNoteDialog/index.js b/apps/mobile/src/components/MoveNoteDialog/index.js
index a4d5c8661..beb758607 100644
--- a/apps/mobile/src/components/MoveNoteDialog/index.js
+++ b/apps/mobile/src/components/MoveNoteDialog/index.js
@@ -159,7 +159,7 @@ class MoveNoteDialog extends React.Component {
height: DDS.isTab ? '90%' : '100%',
borderRadius: DDS.isTab ? 5 : 0,
backgroundColor: colors.bg,
- padding: 8,
+ padding: DDS.isTab ? 8 : 0,
zIndex: 10,
}}>
<Navigator
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js
index 369146ca0..80f0c0c72 100644
--- a/apps/mobile/src/components/NoteItem/index.js
+++ b/apps/mobile/src/components/NoteItem/index.js
@@ -11,9 +11,13 @@ import {DDS} from '../../../App';
import {ph, pv, SIZE, WEIGHT} from '../../common/common';
import NavigationService from '../../services/NavigationService';
import {getElevation, timeSince} from '../../utils/utils';
-import {ActionSheetEvent} from '../DialogManager';
+import {
+ ActionSheetEvent,
+ TEMPLATE_TRASH,
+ simpleDialogEvent,
+} from '../DialogManager';
import {eSendEvent} from '../../services/eventManager';
-import {eOnLoadNote} from '../../services/events';
+import {eOnLoadNote, eOpenSimpleDialog} from '../../services/events';
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
@@ -117,6 +121,8 @@ export default class NoteItem extends React.Component {
} else {
DDS.isTab
? eSendEvent(eOnLoadNote, item)
+ : isTrash
+ ? simpleDialogEvent(TEMPLATE_TRASH(item.type))
: NavigationService.navigate('Editor', {
note: item,
});
@@ -267,10 +273,12 @@ export default class NoteItem extends React.Component {
onPress={() => {
ActionSheetEvent(
item,
- true,
- true,
- ['Add to', 'Share', 'Export', 'Delete'],
- ['Add to Vault', 'Pin', 'Favorite'],
+ isTrash ? false : true,
+ isTrash ? false : true,
+ isTrash
+ ? ['Remove', 'Restore']
+ : ['Add to', 'Share', 'Export', 'Delete'],
+ [],
);
}}>
<Icon name="more-horizontal" size={SIZE.lg} color={colors.icon} />
diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.js
index 4366d20cf..10319e5dc 100644
--- a/apps/mobile/src/components/NotebookItem/index.js
+++ b/apps/mobile/src/components/NotebookItem/index.js
@@ -23,7 +23,7 @@ export const NotebookItem = ({
navigation,
}) => {
const [state, dispatch] = useTracked();
- const {colors} = state;
+ const {colors, selectedItemsList} = state;
const navigate = () => {
isTopic
@@ -100,8 +100,9 @@ export const NotebookItem = ({
flexDirection: 'row',
alignItems: 'center',
marginTop: 5,
- width: '80%',
- maxWidth: '80%',
+ width: '95%',
+ maxWidth: '95%',
+ flexWrap: 'wrap',
}}>
{item && item.topics
? item.topics.slice(1, 4).map(topic => (
@@ -113,6 +114,7 @@ export const NotebookItem = ({
paddingHorizontal: ph / 1.5,
paddingVertical: pv / 4,
marginRight: 10,
+ marginVertical: 4,
}}>
<Text
numberOfLines={1}
@@ -233,6 +235,7 @@ export const NotebookItem = ({
<TouchableOpacity
activeOpacity={opacity}
onPress={async () => {
+ console.log(selectedItemsList, item);
/* if (!noteToMove.notebook.notebook) {
await db.addNoteToTopic(
notebookID,
@@ -247,7 +250,7 @@ export const NotebookItem = ({
});
} */
- moveNoteHideEvent();
+ // moveNoteHideEvent();
ToastEvent.show(
`Note moved to ${item.title}`,
diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.js
index 51c83d0d9..228279b32 100644
--- a/apps/mobile/src/views/Folders/index.js
+++ b/apps/mobile/src/views/Folders/index.js
@@ -34,6 +34,7 @@ export const Folders = ({navigation}) => {
useEffect(() => {
dispatch({type: ACTIONS.NOTEBOOKS});
+ console.log(notebooks);
let backhandler;
if (isFocused) {
backhandler = BackHandler.addEventListener(
diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.js
index de841fd4e..dfb64374d 100644
--- a/apps/mobile/src/views/Notebook/index.js
+++ b/apps/mobile/src/views/Notebook/index.js
@@ -1,4 +1,4 @@
-import React, {useEffect} from 'react';
+import React, {useEffect, useState} from 'react';
import {FlatList, Platform, Text, View} from 'react-native';
import {useIsFocused} from 'react-navigation-hooks';
import {SIZE, WEIGHT} from '../../common/common';
@@ -15,11 +15,17 @@ import {eMoveNoteDialogNavigateBack, eScrollEvent} from '../../services/events';
export const Notebook = ({navigation}) => {
const [state, dispatch] = useTracked();
const {colors, selectionMode, preventDefaultMargins} = state;
-
- const params = navigation.state.params;
+ const [topics, setTopics] = useState([]);
+ let params = navigation.state.params;
let isFocused = useIsFocused();
+ useEffect(() => {
+ let topic = params.notebook.topics;
+
+ setTopics([...topic]);
+ }, []);
+
const handleBackPress = () => {
navigation.goBack();
};
@@ -50,11 +56,11 @@ export const Notebook = ({navigation}) => {
item={item}
index={index}
colors={colors}
- data={params.notebooks.topics}
+ data={topics}
/>
);
- ListFooterComponent = (
+ const ListFooterComponent = (
<View
style={{
height: 150,
@@ -72,15 +78,15 @@ export const Notebook = ({navigation}) => {
</View>
);
- ListHeaderComponent = (
+ const ListHeaderComponent = (
<View
style={{
marginTop:
Platform.OS == 'ios'
- ? params.notebook.topics[0] && !selectionMode
+ ? topics[0] && !selectionMode
? 135
: 135 - 60
- : params.notebook.topics[0] && !selectionMode
+ : topics[0] && !selectionMode
? 155
: 155 - 60,
}}
@@ -95,6 +101,7 @@ export const Notebook = ({navigation}) => {
placeholder={`Search in ${params.title}`}
heading={params.title}
canGoBack={true}
+ data={params.notebook.topics}
bottomButtonOnPress={() => {
//setAddTopic(true);
}}>
@@ -102,7 +109,7 @@ export const Notebook = ({navigation}) => {
style={{
width: '100%',
}}
- data={params.notebook.topics}
+ data={topics}
onScroll={onScroll}
ListHeaderComponent={ListHeaderComponent}
ListFooterComponent={ListFooterComponent}
diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.js
index 6a3c58e2b..b739b3b8a 100644
--- a/apps/mobile/src/views/Notes/index.js
+++ b/apps/mobile/src/views/Notes/index.js
@@ -1,12 +1,17 @@
import React, {useEffect, useState} from 'react';
+import {FlatList, Text, View, Platform} from 'react-native';
import {db} from '../../../App';
import Container from '../../components/Container';
-import {NotesList} from '../../components/NotesList';
+import NoteItem from '../../components/NoteItem';
+import SelectionWrapper from '../../components/SelectionWrapper';
import {useTracked} from '../../provider';
+import {SIZE, WEIGHT} from '../../common/common';
+import {ACTIONS} from '../../provider/actions';
export const Notes = ({navigation}) => {
const [state, dispatch] = useTracked();
-
+ const {colors, selectionMode, currentEditingNote} = state;
+ const allNotes = state.notes;
const [notes, setNotes] = useState([]);
let params = navigation.state ? navigation.state.params : null;
@@ -14,17 +19,90 @@ export const Notes = ({navigation}) => {
useEffect(() => {
if (!params) {
params = {
- heading: 'Notes',
+ title: 'Notes',
};
}
}, []);
useEffect(() => {
- let allNotes = db.getTopic(params.notebookID, params.title);
- if (allNotes && allNotes.length > 0) {
- setNotes(allNotes);
+ if (params.type === 'tag') {
+ let notesInTag = db.getTag(params.tag.title);
+ setNotes([...notesInTag]);
+ } else {
+ let allNotes = db.getTopic(params.notebookID, params.title);
+ if (allNotes && allNotes.length > 0) {
+ setNotes(allNotes);
+ }
}
- }, []);
+ }, [allNotes]);
+
+ const _renderItem = ({item, index}) => (
+ <SelectionWrapper
+ index={index}
+ currentEditingNote={
+ currentEditingNote === item.dateCreated ? currentEditingNote : null
+ }
+ item={item}>
+ <NoteItem
+ colors={colors}
+ customStyle={{
+ width: selectionMode ? '90%' : '100%',
+ marginHorizontal: 0,
+ }}
+ currentEditingNote={
+ currentEditingNote === item.dateCreated ? currentEditingNote : null
+ }
+ onLongPress={() => {
+ dispatch({type: ACTIONS.SELECTION_MODE, enabled: !selectionMode});
+ dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
+ }}
+ update={() => {}}
+ item={item}
+ index={index}
+ />
+ </SelectionWrapper>
+ );
+
+ const _onScroll = event => {
+ if (!event) return;
+ let y = event.nativeEvent.contentOffset.y;
+
+ eSendEvent(eScrollEvent, y);
+ };
+
+ const _ListFooterComponent = notes[0] ? (
+ <View
+ style={{
+ height: 150,
+ alignItems: 'center',
+ justifyContent: 'center',
+ }}>
+ <Text
+ style={{
+ color: colors.navbg,
+ fontSize: SIZE.sm,
+ fontFamily: WEIGHT.regular,
+ }}>
+ - End -
+ </Text>
+ </View>
+ ) : null;
+
+ const _ListHeaderComponent_S = (
+ <View
+ style={{
+ marginTop:
+ Platform.OS == 'ios'
+ ? notes[0]
+ ? 135
+ : 135 - 60
+ : notes[0]
+ ? 155
+ : 155 - 60,
+ }}></View>
+ );
+
+ const _listKeyExtractor = (item, index) => item.dateCreated.toString();
return (
<Container
@@ -35,7 +113,22 @@ export const Notes = ({navigation}) => {
data={notes}
placeholder={`Search in ${params.title}`}
bottomButtonOnPress={() => {}}>
- <NotesList isSearch={false} notes={notes} keyword={null} />
+ <FlatList
+ data={notes}
+ keyExtractor={_listKeyExtractor}
+ ListFooterComponent={_ListFooterComponent}
+ onScroll={_onScroll}
+ ListHeaderComponent={_ListHeaderComponent_S}
+ contentContainerStyle={{
+ width: '100%',
+ alignSelf: 'center',
+ minHeight: '100%',
+ }}
+ style={{
+ height: '100%',
+ }}
+ renderItem={_renderItem}
+ />
</Container>
);
};
diff --git a/apps/mobile/src/views/Tags/index.js b/apps/mobile/src/views/Tags/index.js
index 5541c7186..ea51d758a 100644
--- a/apps/mobile/src/views/Tags/index.js
+++ b/apps/mobile/src/views/Tags/index.js
@@ -1,11 +1,19 @@
import React, {useEffect} from 'react';
-import {Dimensions, FlatList, SafeAreaView, Text, View} from 'react-native';
+import {
+ Dimensions,
+ FlatList,
+ SafeAreaView,
+ Text,
+ View,
+ TouchableOpacity,
+} from 'react-native';
import {pv, SIZE, WEIGHT} from '../../common/common';
import {Header} from '../../components/header';
import {TagsPlaceHolder} from '../../components/ListPlaceholders';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
import {db} from '../../../App';
+import NavigationService from '../../services/NavigationService';
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
@@ -69,7 +77,14 @@ export const Tags = ({navigation}) => {
</View>
}
renderItem={({item, index}) => (
- <View
+ <TouchableOpacity
+ onPress={() => {
+ NavigationService.navigate('Notes', {
+ type: 'tag',
+ title: item.title,
+ tag: item,
+ });
+ }}
style={{
flexDirection: 'row',
justifyContent: 'flex-start',
@@ -101,7 +116,7 @@ export const Tags = ({navigation}) => {
{item.count} note
</Text>
</Text>
- </View>
+ </TouchableOpacity>
)}
/>
</View>