fix signup user

This commit is contained in:
ammarahm-ed
2020-12-20 12:48:08 +05:00
parent afa481a098
commit 1e01974635
7 changed files with 109 additions and 75 deletions

View File

@@ -3,6 +3,7 @@
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain>
<domain includeSubdomains="true">localhost</domain>
<domain includeSubdomains="true">192.168.10.5</domain>
<domain includeSubdomains="true">192.168.10.5</domain>
<domain includeSubdomains="true">192.168.10.10</domain>
</domain-config>
</network-security-config>

View File

@@ -14,7 +14,7 @@ import {
eUnSubscribeEvent,
ToastEvent,
} from '../../services/EventManager';
import {clearMessage} from '../../services/Message';
import {clearMessage, setEmailVerifyMessage} from '../../services/Message';
import {getElevation} from '../../utils';
import {db} from '../../utils/DB';
import {
@@ -177,8 +177,10 @@ const LoginDialog = () => {
try {
await db.user.login(email.toLowerCase(), password, true);
} catch (e) {
console.log(e);
ToastEvent.show(e.message, 'error', 'local');
setLoading(false);
setStatus(null)
return;
}
@@ -197,6 +199,7 @@ const LoginDialog = () => {
ToastEvent.show(`Logged in as ${email}`, 'success', 'local');
} catch (e) {
console.warn(e);
setStatus(null);
ToastEvent.show(e.message, 'error', 'local');
} finally {
setLoading(false);
@@ -241,6 +244,8 @@ const LoginDialog = () => {
await db.user.signup(email, password);
} catch (e) {
setLoading(false);
setStatus(null);
console.log(e);
ToastEvent.show('Signup failed, Network Error', 'error', 'local');
return;
}
@@ -253,10 +258,12 @@ const LoginDialog = () => {
dispatch({type: Actions.LAST_SYNC, lastSync: await db.lastSynced()});
eSendEvent(eStartSyncer);
clearMessage(dispatch);
setEmailVerifyMessage(dispatch)
close();
await sleep(500);
eSendEvent(eOpenRecoveryKeyDialog, true);
} catch (e) {
setStatus(null);
ToastEvent.show('Login Failed, try again', 'error', 'local');
} finally {
setLoading(false);
@@ -559,7 +566,6 @@ const LoginDialog = () => {
onPress={current.buttonAltFunc}
width="100%"
type="shade"
loading={loading}
fontSize={SIZE.md}
style={{
marginTop: 10,

View File

@@ -83,7 +83,7 @@ export const MenuListItem = ({item, index, noTextMode, testID}) => {
/>
{headerTextState?.id === item.name.toLowerCase() + '_navigation' ? (
<Heading color={colors.accent} size={SIZE.md}>
{item.name}
{item.name}
</Heading>
) : (
<Paragraph size={SIZE.md}>{item.name}</Paragraph>

View File

@@ -125,7 +125,7 @@ class RecoveryKeyDialog extends React.Component {
};
onOpen = async () => {
let k = await db.user.key();
let k = await db.user.getEncryptionKey();
this.user = await db.user.getUser();
if (k) {

View File

@@ -1,12 +1,19 @@
import {Platform} from "react-native";
import Storage from "./Storage";
import EventSource from "rn-eventsource";
import AndroidEventSource from "./EventSource";
import Database from "notes-core/api/index";
import {Platform} from 'react-native';
import Storage from './storage';
import EventSource from 'rn-eventsource';
import AndroidEventSource from './event-source';
import Database from 'notes-core/api/index';
global.Buffer = require('buffer').Buffer;
export const db = new Database(
Storage,
Platform.OS === 'ios' ? EventSource : AndroidEventSource,
Storage,
Platform.OS === 'ios' ? EventSource : AndroidEventSource,
);
db.host("https://api.notesnook.com")
//"https://api.notesnook.com"
db.host({
API_HOST: 'http://192.168.10.10:5264',
AUTH_HOST: 'http://192.168.10.10:8264',
SSE_HOST: 'http://192.168.10.10:7264',
});

View File

@@ -143,11 +143,11 @@ export const SUBSCRIPTION_STATUS = {
};
export const SUBSCRIPTION_STATUS_STRINGS = {
0: 'Expired',
0: 'Basic',
1: 'Trial',
2: 'Pro',
3: 'Pro',
4: 'Cancelled',
2: 'Beta',
3: 'Trial Expired',
4: 'Beta Expired',
};
export const BUTTON_TYPES = {

View File

@@ -327,7 +327,7 @@ const CustomButton = ({
const SettingsUserSection = () => {
const [state] = useTracked();
const {colors, user,messageBoardState} = state;
const {colors, user, messageBoardState} = state;
const getTimeLeft = (t2) => {
let d1 = new Date(Date.now());
@@ -340,51 +340,65 @@ const SettingsUserSection = () => {
return (
<>
{messageBoardState && <PressableButton
onPress={messageBoardState.onPress}
customStyle={{
paddingVertical: 12,
width: '100%',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-start',
paddingHorizontal: 6,
}}>
<View
style={{
width: 40,
backgroundColor:messageBoardState.type === "error"? colors.red: colors.accent,
height: 40,
marginLeft: 10,
borderRadius: 100,
{messageBoardState && messageBoardState?.visible && (
<PressableButton
onPress={messageBoardState.onPress}
customStyle={{
paddingVertical: 12,
width: '100%',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
justifyContent: 'flex-start',
paddingHorizontal: 0,
}}>
<Icon size={SIZE.lg} color="white" name={messageBoardState.icon} />
</View>
<View
style={{
width: 40,
backgroundColor:
messageBoardState.type === 'error' ? colors.red : colors.accent,
height: 40,
marginLeft: 10,
borderRadius: 100,
alignItems: 'center',
justifyContent: 'center',
}}>
<Icon size={SIZE.lg} color="white" name={messageBoardState.icon} />
</View>
<View
style={{
marginLeft: 10,
}}>
<Paragraph color={colors.icon} size={SIZE.xs}>
{messageBoardState.message}
</Paragraph>
<Paragraph color={messageBoardState.type === "error"? colors.red: colors.accent}>{messageBoardState.actionText}</Paragraph>
</View>
<View
style={{
marginLeft: 10,
}}>
<Paragraph color={colors.icon} size={SIZE.xs}>
{messageBoardState.message}
</Paragraph>
<Paragraph
color={
messageBoardState.type === 'error' ? colors.red : colors.accent
}>
{messageBoardState.actionText}
</Paragraph>
</View>
<View
style={{
width: 40,
height: 40,
justifyContent: 'center',
alignItems: 'center',
position: 'absolute',
right: 6,
}}>
<Icon name="chevron-right" color={messageBoardState.type === "error"? colors.red: colors.accent} size={SIZE.lg} />
</View>
</PressableButton>}
<View
style={{
width: 40,
height: 40,
justifyContent: 'center',
alignItems: 'center',
position: 'absolute',
right: 6,
}}>
<Icon
name="chevron-right"
color={
messageBoardState.type === 'error' ? colors.red : colors.accent
}
size={SIZE.lg}
/>
</View>
</PressableButton>
)}
{user ? (
<>
@@ -396,7 +410,6 @@ const SettingsUserSection = () => {
style={{
alignSelf: 'center',
width: '100%',
borderRadius: 5,
paddingVertical: 12,
}}>
<View
@@ -404,6 +417,9 @@ const SettingsUserSection = () => {
justifyContent: 'space-between',
alignItems: 'center',
flexDirection: 'row',
borderBottomWidth:1,
paddingBottom:2.5,
borderBottomColor:colors.nav
}}>
<View
style={{
@@ -443,14 +459,15 @@ const SettingsUserSection = () => {
paddingVertical: 2.5,
}}>
<Heading color={colors.accent} size={SIZE.sm}>
{SUBSCRIPTION_STATUS_STRINGS[user.subscription.status]}
{SUBSCRIPTION_STATUS_STRINGS[user.subscription.type]}
</Heading>
</View>
</View>
<Seperator />
<View>
{user.subscription.status === 1 ? (
{user.subscription.type === 1 ||
user.subscription.type === 2 ? (
<View>
<Seperator />
<Paragraph
size={SIZE.lg}
color={
@@ -470,18 +487,21 @@ const SettingsUserSection = () => {
</View>
) : null}
<Seperator />
<Button
onPress={() => {
eSendEvent(eOpenPremiumDialog);
}}
width="100%"
fontSize={SIZE.md}
title="Subscribe to Notesnook Pro"
height={50}
type="accent"
/>
{user.isEmailConfirmed && (
<>
<Seperator />
<Button
onPress={() => {
eSendEvent(eOpenPremiumDialog);
}}
width="100%"
fontSize={SIZE.md}
title="Subscribe to Notesnook Pro"
height={50}
type="accent"
/>
</>
)}
</View>
</View>
</View>