|
@@ -1,26 +1,27 @@
|
|
|
-import { Component, ViewChild } from '@angular/core';
|
|
|
-import { Nav, Platform } from 'ionic-angular';
|
|
|
-import { StatusBar } from '@ionic-native/status-bar';
|
|
|
-import { SplashScreen } from '@ionic-native/splash-screen';
|
|
|
-import { Storage } from '@ionic/storage';
|
|
|
+import { Component, ViewChild } from "@angular/core";
|
|
|
+import { Nav, Platform } from "ionic-angular";
|
|
|
+import { StatusBar } from "@ionic-native/status-bar";
|
|
|
+import { SplashScreen } from "@ionic-native/splash-screen";
|
|
|
+import { Storage } from "@ionic/storage";
|
|
|
|
|
|
-import { AuthProvider } from '../providers/auth/auth';
|
|
|
+import { AuthProvider } from "../providers/auth/auth";
|
|
|
|
|
|
-import { HomePage } from '../pages/home/home';
|
|
|
-import { SearchPage } from '../pages/search/search';
|
|
|
-import { SettingsPage } from '../pages/settings/settings';
|
|
|
-import { LoginPage } from '../pages/login/login';
|
|
|
-import { ProfilePage } from '../pages/profile/profile';
|
|
|
-import { TwitterApiProvider } from '../providers/twitter-api/twitter-api';
|
|
|
+import { HomePage } from "../pages/home/home";
|
|
|
+import { SearchPage } from "../pages/search/search";
|
|
|
+import { SettingsPage } from "../pages/settings/settings";
|
|
|
+import { LoginPage } from "../pages/login/login";
|
|
|
+import { ProfilePage } from "../pages/profile/profile";
|
|
|
+import { TwitterApiProvider } from "../providers/twitter-api/twitter-api";
|
|
|
|
|
|
@Component({
|
|
|
- templateUrl: 'app.html'
|
|
|
+ templateUrl: "app.html"
|
|
|
})
|
|
|
export class MyApp {
|
|
|
- @ViewChild(Nav) nav: Nav;
|
|
|
+ @ViewChild(Nav)
|
|
|
+ nav: Nav;
|
|
|
|
|
|
rootPage: any;
|
|
|
- pages: Array<{ title: string, icon: string, component: any }>;
|
|
|
+ pages: Array<{ title: string; icon: string; component: any }>;
|
|
|
user: any;
|
|
|
|
|
|
constructor(
|
|
@@ -31,29 +32,31 @@ export class MyApp {
|
|
|
private twitter: TwitterApiProvider,
|
|
|
private storage: Storage
|
|
|
) {
|
|
|
- platform.ready().then(() => {
|
|
|
- // Okay, so the platform is ready and our plugins are available.
|
|
|
- // Here you can do any higher level native things you might need.
|
|
|
- //this.setHomepage();
|
|
|
+ platform
|
|
|
+ .ready()
|
|
|
+ .then(() => {
|
|
|
+ // Okay, so the platform is ready and our plugins are available.
|
|
|
+ // Here you can do any higher level native things you might need.
|
|
|
+ //this.setHomepage();
|
|
|
|
|
|
- statusBar.styleDefault();
|
|
|
- splashScreen.hide();
|
|
|
- authProvider.isLoggedIn().then(isLoggedIn => {
|
|
|
+ statusBar.styleDefault();
|
|
|
+ splashScreen.hide();
|
|
|
+
|
|
|
+ return this.authProvider.isLoggedIn();
|
|
|
+ })
|
|
|
+ .then(isLoggedIn => {
|
|
|
this.rootPage = isLoggedIn ? HomePage : LoginPage;
|
|
|
- storage.get("userId")
|
|
|
- .then(userId => {
|
|
|
- twitter.fetchUser(userId)
|
|
|
- .then(res => {
|
|
|
- this.user = res;
|
|
|
- });
|
|
|
- });
|
|
|
+ return this.storage.get("userId");
|
|
|
})
|
|
|
- });
|
|
|
+ .then(userId => this.twitter.fetchUser(userId))
|
|
|
+ .then(res => {
|
|
|
+ this.user = res;
|
|
|
+ });
|
|
|
|
|
|
this.pages = [
|
|
|
- { title: 'Home', icon: 'home', component: HomePage },
|
|
|
- { title: 'Search', icon: 'search', component: SearchPage },
|
|
|
- { title: 'Settings', icon: 'settings', component: SettingsPage }
|
|
|
+ { title: "Home", icon: "home", component: HomePage },
|
|
|
+ { title: "Search", icon: "search", component: SearchPage },
|
|
|
+ { title: "Settings", icon: "settings", component: SettingsPage }
|
|
|
];
|
|
|
}
|
|
|
|
|
@@ -70,4 +73,3 @@ export class MyApp {
|
|
|
this.nav.setRoot(LoginPage);
|
|
|
}
|
|
|
}
|
|
|
-
|