mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
fix adding tags and tag suggestions
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
|||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
View,
|
View,
|
||||||
Platform,
|
Platform,
|
||||||
|
ToastAndroid,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import FastStorage from 'react-native-fast-storage';
|
import FastStorage from 'react-native-fast-storage';
|
||||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||||
@@ -94,7 +95,7 @@ export const ActionSheetComponent = ({
|
|||||||
await db.notes.note(note.id).tag(tag);
|
await db.notes.note(note.id).tag(tag);
|
||||||
|
|
||||||
setNote({...db.notes.note(note.id).data});
|
setNote({...db.notes.note(note.id).data});
|
||||||
|
dispatch({type: ACTIONS.TAGS});
|
||||||
tagToAdd = '';
|
tagToAdd = '';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -127,7 +128,7 @@ export const ActionSheetComponent = ({
|
|||||||
tagsInputRef.current?.setNativeProps({
|
tagsInputRef.current?.setNativeProps({
|
||||||
text: '',
|
text: '',
|
||||||
});
|
});
|
||||||
} else if (event.nativeE.key === ',') {
|
} else if (event.nativeEvent.key === ',') {
|
||||||
_onSubmit();
|
_onSubmit();
|
||||||
tagsInputRef.current?.setNativeProps({
|
tagsInputRef.current?.setNativeProps({
|
||||||
text: '',
|
text: '',
|
||||||
@@ -688,6 +689,77 @@ export const ActionSheetComponent = ({
|
|||||||
style={{
|
style={{
|
||||||
marginHorizontal: 12,
|
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
|
<View
|
||||||
style={{
|
style={{
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
@@ -737,58 +809,6 @@ export const ActionSheetComponent = ({
|
|||||||
onKeyPress={_onKeyPress}
|
onKeyPress={_onKeyPress}
|
||||||
/>
|
/>
|
||||||
</View>
|
</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>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ async function read(key) {
|
|||||||
|
|
||||||
async function write(key, data) {
|
async function write(key, data) {
|
||||||
let json = JSON.stringify(data);
|
let json = JSON.stringify(data);
|
||||||
|
|
||||||
return await FastStorage.setItem(key, json);
|
return await FastStorage.setItem(key, json);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,13 +29,10 @@ function encrypt(password, data) {
|
|||||||
key = aes;
|
key = aes;
|
||||||
return Aes.randomKey(16).then(iv => {
|
return Aes.randomKey(16).then(iv => {
|
||||||
return Aes.encrypt(data, key, iv).then(cipher => {
|
return Aes.encrypt(data, key, iv).then(cipher => {
|
||||||
return Aes.hmac256(cipher, key).then(hash => {
|
return {
|
||||||
return {
|
cipher,
|
||||||
hash,
|
iv,
|
||||||
cipher,
|
};
|
||||||
iv,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -44,14 +42,8 @@ function decrypt(password, data) {
|
|||||||
let key;
|
let key;
|
||||||
return Aes.pbkdf2(password, 'salt', 5000, 256).then(aes => {
|
return Aes.pbkdf2(password, 'salt', 5000, 256).then(aes => {
|
||||||
key = aes;
|
key = aes;
|
||||||
|
return Aes.decrypt(data.cipher, key, data.iv).then(e => {
|
||||||
return Aes.hmac256(data.cipher, key).then(hash => {
|
return e;
|
||||||
if (hash !== data.hash) {
|
|
||||||
throw new Error('Wrong password');
|
|
||||||
}
|
|
||||||
return Aes.decrypt(data.cipher, key, data.iv).then(e => {
|
|
||||||
return e;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user