A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix
ammarahm-edcf4409810c02
diff --git a/apps/mobile/App.js b/apps/mobile/App.jsindex 6919b90a4..37ae80db3 100644--- a/apps/mobile/App.js+++ b/apps/mobile/App.js@@ -134,7 +134,10 @@ const App = () => {useEffect(() => {updateAppTheme().then(() => {- db.init().then(() => {+ db.init().then(async () => {+ let user = await db.user.get();+ dispatch({type: ACTIONS.USER, user: user});+setInit(true);});});diff --git a/apps/mobile/src/components/Menu/index.js b/apps/mobile/src/components/Menu/index.jsindex d64d5769a..861e53f48 100644--- a/apps/mobile/src/components/Menu/index.js+++ b/apps/mobile/src/components/Menu/index.js@@ -10,7 +10,7 @@ import {} from 'react-native';import FastStorage from 'react-native-fast-storage';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import {DDS} from '../../../App';+import {DDS, db} from '../../../App';import {ACCENT,COLOR_SCHEME,@@ -29,6 +29,7 @@ import {ACTIONS} from '../../provider/actions';import {eSendEvent} from '../../services/eventManager';import {eOpenModalMenu, eSendSideMenuOverlayRef} from '../../services/events';import NavigationService from '../../services/NavigationService';+import {timeSince} from '../../utils/utils';export const Menu = ({close = () => {},@@ -37,7 +38,8 @@ export const Menu = ({noTextMode = false,}) => {const [state, dispatch] = useTracked();- const {colors, tags, colorNotes} = state;+ const {colors, tags, colorNotes, user} = state;+// todolet overlayRef;@@ -477,44 +479,6 @@ export const Menu = ({marginBottom: 15,paddingHorizontal: ph,}}>- {/* <TouchableOpacity- onPress={() => {- close();-- DDS.isTab- ? eSendEvent(eOpenLoginDialog)- : NavigationService.navigate('Login');- }}- activeOpacity={opacity / 2}- style={{- paddingVertical: pv + 5,- paddingHorizontal: noTextMode ? 0 : 12,- width: '100%',- justifyContent: noTextMode ? 'center' : 'flex-start',- alignItems: 'center',- flexDirection: 'row',- }}>- <Icon- style={{- minWidth: 40,- }}- name="log-in"- color={colors.accent}- size={SIZE.lg}- />-- {noTextMode ? null : (- <Text- style={{- fontFamily: WEIGHT.regular,- color: colors.accent,- fontSize: SIZE.md,- }}>- {' '}Login- </Text>- )}- </TouchableOpacity> */}-<Viewstyle={{width: '100%',@@ -576,66 +540,113 @@ export const Menu = ({))}</View>- <View- style={{- width: '100%',- borderRadius: 5,- backgroundColor: colors.shade,- }}>+ {user.username ? (<Viewstyle={{- flexDirection: 'row',- justifyContent: 'space-between',- alignItems: 'center',- backgroundColor: colors.accent,+ width: '100%',borderRadius: 5,- paddingHorizontal: 5,- paddingVertical: 5,- elevation: 2,+ backgroundColor: colors.shade,}}>- <Text+ <Viewstyle={{- fontFamily: WEIGHT.regular,- color: 'white',- fontSize: SIZE.xs,+ flexDirection: 'row',+ justifyContent: 'space-between',+ alignItems: 'center',+ backgroundColor: colors.accent,+ borderRadius: 5,+ paddingHorizontal: 5,+ paddingVertical: 5,+ elevation: 2,}}>- <Icon name="account-outline" /> ammarahmed6506- </Text>- <Text+ <Text+ onPress={async () => {+ //await db.sync();+ console.log(await db.sync(), 'SYNCED');+ }}+ style={{+ fontFamily: WEIGHT.regular,+ color: 'white',+ fontSize: SIZE.xs,+ }}>+ <Icon name="account-outline" /> {user.username}+ </Text>+ <Text+ style={{+ fontFamily: WEIGHT.regular,+ fontSize: SIZE.xs,+ color: 'white',+ }}>+ Basic+ </Text>+ </View>++ <Viewstyle={{- fontFamily: WEIGHT.regular,- fontSize: SIZE.xs,- color: 'white',+ flexDirection: 'row',+ justifyContent: 'space-between',+ alignItems: 'center',++ paddingHorizontal: 5,+ paddingVertical: pv,}}>- Basic- </Text>+ <Text+ style={{+ fontFamily: WEIGHT.regular,+ color: colors.pri,+ fontSize: SIZE.xxs,+ }}>+ <Icon color={colors.accent} name="sync" /> Synced{' '}+ {user.lastSynced && user.lastSynced !== 0+ ? timeSince(user.lastSynced)+ : 'never'}+ </Text>++ <Icon+ size={SIZE.sm}+ color={colors.accent}+ name="check-circle-outline"+ />+ </View></View>+ ) : (+ <TouchableOpacity+ onPress={() => {+ close();- <View+ DDS.isTab+ ? eSendEvent(eOpenLoginDialog)+ : NavigationService.navigate('Login');+ }}+ activeOpacity={opacity / 2}style={{- flexDirection: 'row',- justifyContent: 'space-between',+ paddingVertical: pv + 5,+ paddingHorizontal: noTextMode ? 0 : 12,+ width: '100%',+ justifyContent: noTextMode ? 'center' : 'flex-start',alignItems: 'center',-- paddingHorizontal: 5,- paddingVertical: pv,+ flexDirection: 'row',}}>- <Text- style={{- fontFamily: WEIGHT.regular,- color: colors.pri,- fontSize: SIZE.xxs,- }}>- <Icon color={colors.accent} name="sync" /> Synced 3 mins ago.- </Text>-<Icon- size={SIZE.sm}+ style={{+ minWidth: 40,+ }}+ name="log-in"color={colors.accent}- name="check-circle-outline"+ size={SIZE.lg}/>- </View>- </View>++ {noTextMode ? null : (+ <Text+ style={{+ fontFamily: WEIGHT.regular,+ color: colors.accent,+ fontSize: SIZE.md,+ }}>+ {' '}Login+ </Text>+ )}+ </TouchableOpacity>+ )}</View></SafeAreaView>);diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.jsindex 87ad8ce6f..8b8d13217 100755--- a/apps/mobile/src/views/Editor/index.js+++ b/apps/mobile/src/views/Editor/index.js@@ -201,8 +201,10 @@ const Editor = ({navigation, noMenu}) => {}saveCounter++;if (id) {+ console.log(id, 'ID');+let lockednote = db.notes.note(id);- if (lockNote && lockednote.locked) {+ if (lockNote && lockednote && lockednote.locked) {await db.notes.note(id).lock('password');}}@@ -480,8 +482,8 @@ const Editor = ({navigation, noMenu}) => {Platform.OS === 'ios'? {uri: sourceUri}: {- uri: 'http://192.168.10.7:8080/texteditor.html',- baseUrl: 'http://192.168.10.7:8080/',+ uri: 'file:///android_asset/texteditor.html',+ baseUrl: 'file:///android_asset/',}}style={{diff --git a/apps/mobile/src/views/Login/index.js b/apps/mobile/src/views/Login/index.jsindex 97840c3cb..ceb3241e2 100644--- a/apps/mobile/src/views/Login/index.js+++ b/apps/mobile/src/views/Login/index.js@@ -23,6 +23,7 @@ import {} from '../../services/validation';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';import {ToastEvent} from '../../utils/utils';+import {ACTIONS} from '../../provider/actions';export const Login = ({navigation}) => {const [state, dispatch] = useTracked();@@ -33,10 +34,10 @@ export const Login = ({navigation}) => {const _username = createRef();const [loggingIn, setLoggingIn] = useState(false);const [email, setEmail] = useState('');- const [password, setPassword] = useState('');+ const [password, setPassword] = useState('loveyouall123');const [invalidEmail, setInvalidEmail] = useState(false);const [invalidPassword, setInvalidPassword] = useState(false);- const [username, setUsername] = useState('');+ const [username, setUsername] = useState('ammarahmed');const [invalidUsername, setInvalidUsername] = useState(false);const isFocused = useIsFocused();@@ -77,30 +78,29 @@ export const Login = ({navigation}) => {_pass.current.blur();setTimeout(() => {- setStatus('Syncing...');-setTimeout(() => {navigation.navigate('Home');-- ToastEvent.show(`Logged in as ${'ammarahmed'}`, 'success');}, 500);}, 300);-- return;+ setStatus('Logging in...');if (!invalidPassword && !invalidUsername) {try {await db.user.login(username, password);} catch (e) {- console.log(e, 'signup');+ console.log(e);+ setLoggingIn(false);}let user;try {- user = await db.user.user.get();+ user = await db.user.get();+ console.log('user', user);dispatch({type: ACTIONS.USER, user: user});+ ToastEvent.show(`Logged in as ${'ammarahmed'}`, 'success');} catch (e) {- console.log('e', 'getUSer');+ console.log(e, 'getUSer');+ ToastEvent.show(`Login Failed`, 'error');}console.log(user);diff --git a/apps/mobile/src/views/Signup/index.js b/apps/mobile/src/views/Signup/index.jsindex db480e62f..9eb7d0fa9 100644--- a/apps/mobile/src/views/Signup/index.js+++ b/apps/mobile/src/views/Signup/index.js@@ -8,7 +8,7 @@ import {Header} from '../../components/header';import {useTracked} from '../../provider';import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/eventManager';import {eLoginDialogNavigateBack} from '../../services/events';-+import * as Animatable from 'react-native-animatable';const _email = createRef();const _pass = createRef();const _username = createRef();@@ -24,14 +24,15 @@ import {ACTIONS} from '../../provider/actions';export const Signup = ({navigation}) => {const [state, dispatch] = useTracked();const {colors, isLoginNavigator} = state;-+ const [signingIn, setSigningIn] = useState(false);+ const [status, setStatus] = useState('Creating new user...');const [email, setEmail] = useState('');const [password, setPassword] = useState('');const [username, setUsername] = useState('');const [invalidUsername, setInvalidUsername] = useState(false);const [invalidEmail, setInvalidEmail] = useState(false);const [invalidPassword, setInvalidPassword] = useState(false);-+ const [failed, setFailed] = useState(false);let isFocused = useIsFocused();const handleBackPress = () => {@@ -46,20 +47,36 @@ export const Signup = ({navigation}) => {}, [isFocused]);const _signUp = async () => {+ setSigningIn(true);+ setStatus('Creating new user...');if (!invalidEmail && !invalidPassword && !invalidUsername) {try {await db.user.signup(username, email, password);} catch (e) {console.log(e, 'signup');+ setSigningIn(false);+ setFailed(true);+ ToastEvent.show('Signup failed, Network Error', 'error');+ return;}let user;+ setStatus('Logging you in...');try {user = await db.user.user.get();dispatch({type: ACTIONS.USER, user: user});++ setTimeout(() => {+ navigation.navigate('Home');++ ToastEvent.show(`Logged in as ${'ammarahmed'}`, 'success');+ }, 500);} catch (e) {console.log('e', 'getUSer');+ setSigningIn(false);+ setFailed(true);+ ToastEvent.show('Login Failed, try again', 'error');}console.log(user);@@ -74,311 +91,344 @@ export const Signup = ({navigation}) => {height: '100%',backgroundColor: colors.bg,}}>- <Header- isLoginNavigator={isLoginNavigator}- navigation={navigation}- colors={colors}- heading="Create Account"- />+ {signingIn ? (+ <Animatable.View+ transition="opacity"+ useNativeDriver={true}+ duration={150}+ style={{+ width: '100%',+ height: '100%',+ justifyContent: 'center',+ alignItems: 'center',+ zIndex: 999,+ backgroundColor: colors.bg,+ opacity: 1,+ position: 'absolute',+ }}>+ <ActivityIndicator color={colors.accent} size={SIZE.xxxl} />- <View- style={{- justifyContent: DDS.isTab ? 'center' : 'flex-start',- width: DDS.isTab ? '80%' : '100%',- height: DDS.isTab ? '80%' : '100%',- alignSelf: 'center',- }}>- <View><Textstyle={{- textAlign: 'right',- marginHorizontal: 12,+ color: colors.accent,fontFamily: WEIGHT.regular,-- textAlignVertical: 'bottom',-- position: 'absolute',- right: 5,- top: 2.5,+ fontSize: SIZE.md,+ marginTop: 10,}}>- {invalidUsername ? (- <Icon- name="alert-circle-outline"- size={SIZE.xs}- color={colors.errorText}- />- ) : null}+ {status}</Text>+ </Animatable.View>+ ) : null}- <TextInput- ref={_username}- onFocus={() => {- if (!invalidUsername) {- _username.current.setNativeProps({- style: {- borderColor: colors.accent,- },- });- }- }}- defaultValue={username}- onBlur={() => {- if (!validateUsername(username)) {- setInvalidUsername(true);- _username.current.setNativeProps({- style: {- color: colors.errorText,- borderColor: colors.errorText,- },- });- } else {- _username.current.setNativeProps({- style: {- borderColor: colors.nav,- },- });- }- }}- textContentType="username"- onChangeText={value => {- setUsername(value);-- if (invalidUsername && validateUsername(username)) {- setInvalidUsername(false);- _username.current.setNativeProps({- style: {- color: colors.pri,- borderColor: colors.accent,- },- });- }- }}- onSubmitEditing={() => {- if (!validateUsername(username)) {- setInvalidUsername(true);- _username.current.setNativeProps({- style: {- color: colors.errorText,- },- });- }- }}- style={{- padding: pv,- borderWidth: 1.5,- borderColor: colors.nav,- marginHorizontal: 12,- borderRadius: 5,- fontSize: SIZE.sm,- fontFamily: WEIGHT.regular,- }}- placeholder="Username (a-z _- 0-9)"- placeholderTextColor={colors.icon}+ {signingIn ? null : (+ <>+ <Header+ isLoginNavigator={isLoginNavigator}+ navigation={navigation}+ colors={colors}+ heading="Create Account"/><Viewstyle={{- marginTop: 15,+ justifyContent: DDS.isTab ? 'center' : 'flex-start',+ width: DDS.isTab ? '80%' : '100%',+ height: DDS.isTab ? '80%' : '100%',+ alignSelf: 'center',}}>- <Text- style={{- textAlign: 'right',- marginHorizontal: 12,- fontFamily: WEIGHT.regular,+ <View>+ <Text+ style={{+ textAlign: 'right',+ marginHorizontal: 12,+ fontFamily: WEIGHT.regular,- textAlignVertical: 'bottom',+ textAlignVertical: 'bottom',- position: 'absolute',- right: 5,- top: 2.5,- }}>- {invalidEmail ? (- <Icon- name="alert-circle-outline"- size={SIZE.xs}- color={colors.errorText}- />- ) : null}- </Text>+ position: 'absolute',+ right: 5,+ top: 2.5,+ }}>+ {invalidUsername ? (+ <Icon+ name="alert-circle-outline"+ size={SIZE.xs}+ color={colors.errorText}+ />+ ) : null}+ </Text>- <TextInput- ref={_email}- onFocus={() => {- if (!invalidEmail) {- _email.current.setNativeProps({- style: {- borderColor: colors.accent,- },- });- }- }}- defaultValue={email}- onBlur={() => {- if (!validateEmail(email)) {- setInvalidEmail(true);- _email.current.setNativeProps({- style: {- color: colors.errorText,- borderColor: colors.errorText,- },- });- } else {- _email.current.setNativeProps({- style: {- borderColor: colors.nav,- },- });- }- }}- textContentType="emailAddress"- onChangeText={value => {- setEmail(value);- if (invalidEmail && validateEmail(email)) {- setInvalidEmail(false);- _email.current.setNativeProps({- style: {- color: colors.pri,- borderColor: colors.accent,- },- });- }- }}- onSubmitEditing={() => {- if (!validateEmail(email)) {- setInvalidEmail(true);- _email.current.setNativeProps({- style: {- color: colors.errorText,- },- });- }- }}- style={{- padding: pv,- borderWidth: 1.5,- borderColor: colors.nav,- marginHorizontal: 12,- borderRadius: 5,- fontSize: SIZE.sm,- fontFamily: WEIGHT.regular,- }}- placeholder="Email"- placeholderTextColor={colors.icon}- />- </View>+ <TextInput+ ref={_username}+ onFocus={() => {+ if (!invalidUsername) {+ _username.current.setNativeProps({+ style: {+ borderColor: colors.accent,+ },+ });+ }+ }}+ defaultValue={username}+ onBlur={() => {+ if (!validateUsername(username)) {+ setInvalidUsername(true);+ _username.current.setNativeProps({+ style: {+ color: colors.errorText,+ borderColor: colors.errorText,+ },+ });+ } else {+ _username.current.setNativeProps({+ style: {+ borderColor: colors.nav,+ },+ });+ }+ }}+ textContentType="username"+ onChangeText={value => {+ setUsername(value);- <View- style={{- marginTop: 15,- marginBottom: 15,- }}>- <Text- style={{- textAlign: 'right',- marginHorizontal: 12,- fontFamily: WEIGHT.regular,+ if (invalidUsername && validateUsername(username)) {+ setInvalidUsername(false);+ _username.current.setNativeProps({+ style: {+ color: colors.pri,+ borderColor: colors.accent,+ },+ });+ }+ }}+ onSubmitEditing={() => {+ if (!validateUsername(username)) {+ setInvalidUsername(true);+ _username.current.setNativeProps({+ style: {+ color: colors.errorText,+ },+ });+ }+ }}+ style={{+ padding: pv,+ borderWidth: 1.5,+ borderColor: colors.nav,+ marginHorizontal: 12,+ borderRadius: 5,+ fontSize: SIZE.sm,+ fontFamily: WEIGHT.regular,+ }}+ placeholder="Username (a-z _- 0-9)"+ placeholderTextColor={colors.icon}+ />++ <View+ style={{+ marginTop: 15,+ }}>+ <Text+ style={{+ textAlign: 'right',+ marginHorizontal: 12,+ fontFamily: WEIGHT.regular,++ textAlignVertical: 'bottom',++ position: 'absolute',+ right: 5,+ top: 2.5,+ }}>+ {invalidEmail ? (+ <Icon+ name="alert-circle-outline"+ size={SIZE.xs}+ color={colors.errorText}+ />+ ) : null}+ </Text>- textAlignVertical: 'bottom',- position: 'absolute',- right: 5,- top: 2.5,- }}>- {invalidPassword ? (- <Icon- name="alert-circle-outline"- size={SIZE.xs}- color={colors.errorText}+ <TextInput+ ref={_email}+ onFocus={() => {+ if (!invalidEmail) {+ _email.current.setNativeProps({+ style: {+ borderColor: colors.accent,+ },+ });+ }+ }}+ defaultValue={email}+ onBlur={() => {+ if (!validateEmail(email)) {+ setInvalidEmail(true);+ _email.current.setNativeProps({+ style: {+ color: colors.errorText,+ borderColor: colors.errorText,+ },+ });+ } else {+ _email.current.setNativeProps({+ style: {+ borderColor: colors.nav,+ },+ });+ }+ }}+ textContentType="emailAddress"+ onChangeText={value => {+ setEmail(value);+ if (invalidEmail && validateEmail(email)) {+ setInvalidEmail(false);+ _email.current.setNativeProps({+ style: {+ color: colors.pri,+ borderColor: colors.accent,+ },+ });+ }+ }}+ onSubmitEditing={() => {+ if (!validateEmail(email)) {+ setInvalidEmail(true);+ _email.current.setNativeProps({+ style: {+ color: colors.errorText,+ },+ });+ }+ }}+ style={{+ padding: pv,+ borderWidth: 1.5,+ borderColor: colors.nav,+ marginHorizontal: 12,+ borderRadius: 5,+ fontSize: SIZE.sm,+ fontFamily: WEIGHT.regular,+ }}+ placeholder="Email"+ placeholderTextColor={colors.icon}/>- ) : null}- </Text>- <TextInput- ref={_pass}- onFocus={() => {- if (!invalidPassword) {- _pass.current.setNativeProps({- style: {- borderColor: colors.accent,- },- });- }- }}- defaultValue={password}- onBlur={() => {- if (!validatePass(password)) {- setInvalidPassword(true);- _pass.current.setNativeProps({- style: {- color: colors.errorText,- borderColor: colors.errorText,- },- });- } else {- _pass.current.setNativeProps({- style: {- borderColor: colors.nav,- },- });- }- }}- onChangeText={value => {- setPassword(value);+ </View>++ <View+ style={{+ marginTop: 15,+ marginBottom: 15,+ }}>+ <Text+ style={{+ textAlign: 'right',+ marginHorizontal: 12,+ fontFamily: WEIGHT.regular,- if (invalidPassword && validatePass(password)) {- setInvalidPassword(false);- _pass.current.setNativeProps({- style: {- color: colors.pri,- borderColor: colors.accent,- },- });- }- }}- onSubmitEditing={() => {- if (!validatePass(password)) {- setInvalidPassword(true);- _pass.current.setNativeProps({- style: {- color: colors.errorText,- },- });- }- }}- style={{- padding: pv,- borderWidth: 1.5,- borderColor: colors.nav,- marginHorizontal: 12,- borderRadius: 5,- fontSize: SIZE.sm,- fontFamily: WEIGHT.regular,- }}- secureTextEntry={true}- placeholder="Password"- placeholderTextColor={colors.icon}- />+ textAlignVertical: 'bottom',+ position: 'absolute',+ right: 5,+ top: 2.5,+ }}>+ {invalidPassword ? (+ <Icon+ name="alert-circle-outline"+ size={SIZE.xs}+ color={colors.errorText}+ />+ ) : null}+ </Text>+ <TextInput+ ref={_pass}+ onFocus={() => {+ if (!invalidPassword) {+ _pass.current.setNativeProps({+ style: {+ borderColor: colors.accent,+ },+ });+ }+ }}+ defaultValue={password}+ onBlur={() => {+ if (!validatePass(password)) {+ setInvalidPassword(true);+ _pass.current.setNativeProps({+ style: {+ color: colors.errorText,+ borderColor: colors.errorText,+ },+ });+ } else {+ _pass.current.setNativeProps({+ style: {+ borderColor: colors.nav,+ },+ });+ }+ }}+ onChangeText={value => {+ setPassword(value);++ if (invalidPassword && validatePass(password)) {+ setInvalidPassword(false);+ _pass.current.setNativeProps({+ style: {+ color: colors.pri,+ borderColor: colors.accent,+ },+ });+ }+ }}+ onSubmitEditing={() => {+ if (!validatePass(password)) {+ setInvalidPassword(true);+ _pass.current.setNativeProps({+ style: {+ color: colors.errorText,+ },+ });+ }+ }}+ style={{+ padding: pv,+ borderWidth: 1.5,+ borderColor: colors.nav,+ marginHorizontal: 12,+ borderRadius: 5,+ fontSize: SIZE.sm,+ fontFamily: WEIGHT.regular,+ }}+ secureTextEntry={true}+ placeholder="Password"+ placeholderTextColor={colors.icon}+ />+ </View>+ <TouchableOpacity+ activeOpacity={opacity}+ onPress={_signUp}+ style={{+ padding: pv,+ backgroundColor: colors.accent,+ borderRadius: 5,+ marginHorizontal: 12,+ marginBottom: 10,+ alignItems: 'center',+ }}>+ <Text+ style={{+ fontSize: SIZE.md,+ fontFamily: WEIGHT.medium,+ color: 'white',+ }}>+ Signup+ </Text>+ </TouchableOpacity>+ </View></View>- <TouchableOpacity- activeOpacity={opacity}- onPress={_signUp}- style={{- padding: pv,- backgroundColor: colors.accent,- borderRadius: 5,- marginHorizontal: 12,- marginBottom: 10,- alignItems: 'center',- }}>- <Text- style={{- fontSize: SIZE.md,- fontFamily: WEIGHT.medium,- color: 'white',- }}>- Signup- </Text>- </TouchableOpacity>- </View>- </View>+ </>+ )}</SafeAreaView>);};