diff --git a/src/CONFIG.js b/src/CONFIG.js index 10512520c48..7dcfe5902d0 100644 --- a/src/CONFIG.js +++ b/src/CONFIG.js @@ -1,5 +1,6 @@ -// TODO: Figure out how to determine prod/dev on mobile, etc. -const IS_IN_PRODUCTION = false; +import {Platform} from 'react-native'; + +const IS_IN_PRODUCTION = Platform.OS === 'web' ? process.env.NODE_ENV === 'production' : !__DEV__; export default { PUSHER: { diff --git a/src/lib/Str.js b/src/lib/Str.js index d8660585d8c..b768528bc0c 100644 --- a/src/lib/Str.js +++ b/src/lib/Str.js @@ -1,5 +1,7 @@ /* globals $, _ */ +import Guid from './Guid'; + const Str = { /** * Returns the proper phrase depending on the count that is passed. @@ -49,6 +51,15 @@ const Str = { nl2br(str) { return str.replace(/\n/g, '
'); }, + + /** + * Generates a random device login using Guid + * + * @returns {string} + */ + generateDeviceLoginID() { + return `React-Native-Chat-${Guid()}`; + }, }; export default Str; diff --git a/src/page/SignInPage.js b/src/page/SignInPage.js index 80cc4e111b4..86d1d6c1d07 100644 --- a/src/page/SignInPage.js +++ b/src/page/SignInPage.js @@ -27,13 +27,14 @@ export default class App extends Component { login: '', password: '', // eslint-disable-next-line react/no-unused-state - error: Store.get(STOREKEYS.SESSION, 'error'), + error: null, }; } componentDidMount() { // Listen for changes to our session Store.subscribe(STOREKEYS.SESSION, this.sessionChanged); + Store.get(STOREKEYS.SESSION, 'error').then(error => this.setState({error})); } componentWillUnmount() { @@ -54,7 +55,7 @@ export default class App extends Component { * When the form is submitted, then we trigger our prop callback */ submit() { - signIn(this.state.login, this.state.password); + signIn(this.state.login, this.state.password, true); } render() { @@ -81,6 +82,9 @@ export default class App extends Component {