From f7d4f87c2ebdee6f116eb036af52ca9173846d2a Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Mon, 6 Jan 2020 16:15:47 +0500 Subject: [PATCH] fully implemented vault system. --- apps/mobile/src/components/NoteItem/index.js | 33 +++++++++--------- apps/mobile/src/views/Editor/index.js | 36 ++++++-------------- apps/mobile/src/views/Folders/index.js | 5 ++- apps/mobile/src/views/Trash/index.js | 1 + 4 files changed, 31 insertions(+), 44 deletions(-) diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js index e9c3fa53d..b72ee664d 100644 --- a/apps/mobile/src/components/NoteItem/index.js +++ b/apps/mobile/src/components/NoteItem/index.js @@ -1,8 +1,6 @@ import React, {useState} from 'react'; import {View, Text, TouchableOpacity, Dimensions} from 'react-native'; - import {COLOR_SCHEME, SIZE, br, ph, pv, WEIGHT} from '../../common/common'; - import Icon from 'react-native-vector-icons/Feather'; import { timeSince, @@ -188,19 +186,23 @@ const NoteItem = props => { }}> {!props.isTrash ? ( <> - - + {item.locked ? ( + + ) : null} + {item.favorite ? ( + + ) : null} { textAlignVertical: 'center', fontFamily: WEIGHT.regular, }}> - {timeSince(item.dateCreated) + ' '} + {timeSince(item.dateCreated)} ) : null} @@ -342,7 +344,6 @@ const NoteItem = props => { hideMenu(); NavigationService.push('Folders', { note: item, - title: 'Choose Notebook', isMove: true, hideMore: true, diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js index e40434068..388cd933a 100755 --- a/apps/mobile/src/views/Editor/index.js +++ b/apps/mobile/src/views/Editor/index.js @@ -64,13 +64,14 @@ const Editor = ({navigation}) => { } }; - const saveNote = async (noteProps = {}, lockNote = false) => { + const saveNote = async (noteProps = {}, lockNote = true) => { if (!content) { content = { text: '', delta: null, }; } + console.log(content.text, timestamp, title); timestamp = await db.addNote({ tags: noteProps.tags, @@ -85,9 +86,8 @@ const Editor = ({navigation}) => { }, dateCreated: timestamp, }); - + console.log(db.getNote(timestamp)); if (lockNote && noteProps.locked) { - console.log(noteProps, timestamp); db.lockNote(timestamp, 'password'); } }; @@ -96,7 +96,6 @@ const Editor = ({navigation}) => { post(JSON.stringify(colors)); if (navigation.state.params && navigation.state.params.note) { note = navigation.state.params.note; - updateEditor(); } }; @@ -119,7 +118,6 @@ const Editor = ({navigation}) => { timestamp = note.dateCreated; content = note.content; }, 200); - console.log(note); }; const onTitleTextChange = value => { @@ -242,11 +240,13 @@ const Editor = ({navigation}) => { }} onMessage={evt => { if (evt.nativeEvent.data !== '') { + clearTimeout(timer); timer = null; onChange(evt.nativeEvent.data); timer = setTimeout(() => { saveNote(noteProps, true); - }, 2000); + console.log('saved'); + }, 1000); } }} /> @@ -265,26 +265,12 @@ const Editor = ({navigation}) => { return () => { handleBack.remove(); handleBack = null; - }; - }, []); - - useEffect(() => { - console.log('hello'); - updateInterval = setInterval(async function() { - await saveNote(noteProps); - }, 2000); - - return () => { - saveNote(noteProps, true); - clearInterval(updateInterval); - updateInterval = null; - console.log('yeah'); title = null; content = null; timer = null; timestamp = null; }; - }, [noteProps]); + }, []); useEffect(() => { return () => { @@ -320,8 +306,10 @@ const Editor = ({navigation}) => { setDialog(false); }} positivePress={() => { - navigation.goBack(); - setDialog(false); + setTimeout(() => { + navigation.goBack(); + setDialog(false); + }, 1000); }} /> {_renderEditor()} @@ -338,8 +326,6 @@ const Editor = ({navigation}) => { noteProps={noteProps} updateProps={props => { setNoteProps(props); - - console.log(props, noteProps); }} close={() => { setTimeout(() => { diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.js index 9ffacff92..374f31f20 100644 --- a/apps/mobile/src/views/Folders/index.js +++ b/apps/mobile/src/views/Folders/index.js @@ -517,7 +517,6 @@ export const Folders = ({navigation}) => { width: '90%', marginHorizontal: '5%', paddingHorizontal: ph, - paddingVertical: pv + 5, flexDirection: 'row', justifyContent: 'flex-start', @@ -529,10 +528,10 @@ export const Folders = ({navigation}) => { - {' '} Create a new notebook + {' '}Create a new notebook diff --git a/apps/mobile/src/views/Trash/index.js b/apps/mobile/src/views/Trash/index.js index e53a97610..811cff43c 100644 --- a/apps/mobile/src/views/Trash/index.js +++ b/apps/mobile/src/views/Trash/index.js @@ -33,6 +33,7 @@ export const Trash = ({navigation}) => { item.dateCreated.toString()} style={{ width: '100%', alignSelf: 'center',