From 898c7d277a8a9ee0821e89e5f84a17f5c20de09e Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 8 Aug 2020 11:43:31 -0700 Subject: [PATCH 1/6] Implement infinite sessions --- src/lib/Str.js | 6 ++ src/page/SignInPage.js | 8 ++- src/store/actions/SessionActions.js | 100 +++++++++++++++++----------- 3 files changed, 73 insertions(+), 41 deletions(-) diff --git a/src/lib/Str.js b/src/lib/Str.js index d8660585d8c..b6e5c3c33e1 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,10 @@ const Str = { nl2br(str) { return str.replace(/\n/g, '
'); }, + + generateDeviceLoginID() { + return `React-Native-Chat-${Guid()}`; + }, }; export default Str; diff --git a/src/page/SignInPage.js b/src/page/SignInPage.js index 90b6427c93c..b54f0fc3e54 100644 --- a/src/page/SignInPage.js +++ b/src/page/SignInPage.js @@ -26,13 +26,14 @@ export default class App extends Component { this.state = { login: '', password: '', - error: Store.get(STOREKEYS.SESSION, 'error'), + error: '', }; } componentDidMount() { // Listen for changes to our session Store.subscribe(STOREKEYS.SESSION, this.sessionChanged); + Store.get(STOREKEYS.SESSION, 'error').then(error => this.state.error = error); } componentWillUnmount() { @@ -52,7 +53,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() { @@ -79,6 +80,9 @@ export default class App extends Component {