Skip to content

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

fix adding tags and tag suggestions

ammarahm-edc637f1f35c83
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,
}}>
+ <View
+ style={{
+ flexDirection: 'row',
+ flexWrap: 'wrap',
+ marginBottom: 5,
+ marginTop: 5,
+ alignItems: 'center',
+ }}>
+ <Text
+ style={{
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.xs,
+ color: colors.accent,
+ }}>
+ Suggestions:{' '}
+ </Text>
+ {tags
+ .filter(o => o.count > 1 && !note.tags.find(t => t === o.title))
+ .map(tag => (
+ <TouchableOpacity
+ key={tag.title}
+ onPress={() => {
+ 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,
+ }}>
+ <Text
+ style={{
+ fontFamily: WEIGHT.regular,
+ fontSize: SIZE.xs,
+ color: colors.pri,
+ }}>
+ <Text
+ style={{
+ color: colors.accent,
+ }}>
+ #
+ </Text>
+ {tag.title}{' '}
+ </Text>
+ <View
+ style={{
+ borderRadius: 2.5,
+ backgroundColor: colors.accent,
+ alignItems: 'center',
+ justifyContent: 'center',
+ }}>
+ <Text
+ style={{
+ color: 'white',
+ fontSize: SIZE.xxs - 2,
+ minWidth: 12,
+ textAlign: 'center',
+ }}>
+ {tag.count}
+ </Text>
+ </View>
+ </TouchableOpacity>
+ ))}
+ </View>
<View
style={{
flexDirection: 'row',
@@ -737,58 +809,6 @@ export const ActionSheetComponent = ({
onKeyPress={_onKeyPress}
/>
</View>
- <View
- style={{
- flexDirection: 'row',
- flexWrap: 'wrap',
- marginBottom: 5,
- marginTop: 5,
- alignItems: 'center',
- }}>
- <Text
- style={{
- fontFamily: WEIGHT.regular,
- fontSize: SIZE.xs,
- color: colors.accent,
- }}>
- Suggestions:{' '}
- </Text>
- {tags
- .filter(o => o.count > 1)
- .map(tag => (
- <TouchableOpacity
- key={tag}
- onPress={async () => {}}
- 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,
- }}>
- <Text
- style={{
- fontFamily: WEIGHT.regular,
- fontSize: SIZE.xs,
- color: colors.pri,
- }}>
- <Text
- style={{
- color: colors.accent,
- }}>
- #
- </Text>
- {tag.title}
- </Text>
- </TouchableOpacity>
- ))}
- </View>
</View>
) : 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;
});
});
}