diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js index e6390a98a..633fcc83e 100644 --- a/apps/mobile/src/components/ActionSheetComponent/index.js +++ b/apps/mobile/src/components/ActionSheetComponent/index.js @@ -7,6 +7,7 @@ import { TouchableOpacity, View, Platform, + ToastAndroid, } from 'react-native'; import FastStorage from 'react-native-fast-storage'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; @@ -94,7 +95,7 @@ export const ActionSheetComponent = ({ await db.notes.note(note.id).tag(tag); setNote({...db.notes.note(note.id).data}); - + dispatch({type: ACTIONS.TAGS}); tagToAdd = ''; }; @@ -127,7 +128,7 @@ export const ActionSheetComponent = ({ tagsInputRef.current?.setNativeProps({ text: '', }); - } else if (event.nativeE.key === ',') { + } else if (event.nativeEvent.key === ',') { _onSubmit(); tagsInputRef.current?.setNativeProps({ text: '', @@ -688,6 +689,77 @@ export const ActionSheetComponent = ({ style={{ marginHorizontal: 12, }}> + + + Suggestions:{' '} + + {tags + .filter(o => o.count > 1 && !note.tags.find(t => t === o.title)) + .map(tag => ( + { + tagToAdd = tag.title; + _onSubmit(); + }} + style={{ + flexDirection: 'row', + justifyContent: 'flex-start', + alignItems: 'center', + margin: 1, + marginRight: 5, + paddingHorizontal: 5, + paddingVertical: 1, + borderRadius: 2.5, + borderBottomWidth: 1, + borderBottomColor: colors.nav, + }}> + + + # + + {tag.title}{' '} + + + + {tag.count} + + + + ))} + - - - Suggestions:{' '} - - {tags - .filter(o => o.count > 1) - .map(tag => ( - {}} - style={{ - flexDirection: 'row', - justifyContent: 'flex-start', - alignItems: 'center', - margin: 1, - marginRight: 3, - paddingHorizontal: 5, - paddingVertical: 1, - backgroundColor: Platform.ios - ? hexToRGBA(colors.accent + '19') - : hexToRGBA(colors.shade), - borderRadius: 2.5, - }}> - - - # - - {tag.title} - - - ))} - ) : null} diff --git a/apps/mobile/src/utils/storage.js b/apps/mobile/src/utils/storage.js index d98f34c21..fcb3c4a29 100644 --- a/apps/mobile/src/utils/storage.js +++ b/apps/mobile/src/utils/storage.js @@ -11,6 +11,7 @@ async function read(key) { async function write(key, data) { let json = JSON.stringify(data); + return await FastStorage.setItem(key, json); } @@ -28,13 +29,10 @@ function encrypt(password, data) { key = aes; return Aes.randomKey(16).then(iv => { return Aes.encrypt(data, key, iv).then(cipher => { - return Aes.hmac256(cipher, key).then(hash => { - return { - hash, - cipher, - iv, - }; - }); + return { + cipher, + iv, + }; }); }); }); @@ -44,14 +42,8 @@ function decrypt(password, data) { let key; return Aes.pbkdf2(password, 'salt', 5000, 256).then(aes => { key = aes; - - return Aes.hmac256(data.cipher, key).then(hash => { - if (hash !== data.hash) { - throw new Error('Wrong password'); - } - return Aes.decrypt(data.cipher, key, data.iv).then(e => { - return e; - }); + return Aes.decrypt(data.cipher, key, data.iv).then(e => { + return e; }); }); }