From ba2acc32951c66ccdd030761419e28e19c12c63c Mon Sep 17 00:00:00 2001 From: Mathieu Nayrolles Date: Mon, 13 Mar 2017 19:08:05 -0400 Subject: [PATCH] fix(signup): Signup screen isn't dismiss when coming back from background Tweak of the onResume event to prevent redirection towards the signup screen when the API key expired or isn't present Fixes #98 --- src/app/app.module.ts | 8 ++++---- src/pages/login/login.ts | 11 ++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index fa515ee..e56a494 100755 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -3,7 +3,7 @@ import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular'; import { MyApp } from './app.component'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { HttpModule, Http } from '@angular/http'; -import { Storage } from '@ionic/storage'; +import { IonicStorageModule } from '@ionic/storage'; import {BrowserModule} from '@angular/platform-browser'; //Ionic Pages @@ -22,17 +22,16 @@ import { Header } from '../components/header/header'; import { MobileError } from '../components/mobile-error/mobile-error'; import { MobileInput } from '../components/mobile-input/mobile-input'; -//Common Pipes -import { TranslateModule, TranslateStaticLoader, TranslateLoader } from 'ng2-translate/ng2-translate'; +import { TranslateModule, TranslateLoader, TranslateStaticLoader } from 'ng2-translate/ng2-translate'; import { TwAPIService, GAService } from 'tw-core'; - import { TwCoreModule } from 'tw-core'; export function createTranslateLoader(http: Http) { return new TranslateStaticLoader(http, './assets/i18n', '.json'); } + @NgModule({ declarations: [ MyApp, @@ -56,6 +55,7 @@ export function createTranslateLoader(http: Http) { ReactiveFormsModule, BrowserModule, HttpModule, + IonicStorageModule.forRoot(), TranslateModule.forRoot({ provide: TranslateLoader, useFactory: (createTranslateLoader), diff --git a/src/pages/login/login.ts b/src/pages/login/login.ts index 1fc3962..661654b 100755 --- a/src/pages/login/login.ts +++ b/src/pages/login/login.ts @@ -221,9 +221,13 @@ export class LogInPage extends LoginComponent{ this.loginAttempt.emit(false); }, error => { - console.log("API Key changed"); - this.loginAttempt.emit(false); - this.nav.setRoot(LogInPage); + this.loginAttempt.emit(false); + + //In case the user were on the signup page, let him be + //https://github.com/Toolwatchapp/tw-mobile/issues/98 + if(this.nav.getActive().name != "SignupPage"){ + this.nav.setRoot(LogInPage); + } } ); @@ -245,6 +249,7 @@ export class LogInPage extends LoginComponent{ this.loginAttempt.emit(true); return key; }else{ + console.log(this.nav.getActive().name) throw new Error("No valid key"); } });