From db9cd43d58968e6f73530fe2fd26a35a0bdb5234 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Tue, 5 Sep 2017 20:50:16 -0700 Subject: [PATCH] Added setting for default timeline, issue #40 --- src/app/app.component.ts | 22 +++++++++++++++++----- src/pages/settings/settings.html | 8 ++++++++ src/pages/settings/settings.ts | 11 +++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 52cbb32..7791ef2 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -45,14 +45,14 @@ export class MyApp { // Okay, so the platform is ready and our plugins are available. // Here you can do any higher level native things you might need. - this.storage.get('token').then((val) => { + this.storage.get('timeline').then((val) => { if (val.length > 1) { - pnut.token = val; - this.nav.setRoot(StreamPage, {stream: 'personal'}); + this.initialPage(val); + } else { + console.log('ERR WHUT?'); } }).catch(err => { - console.log('ERROR: ' + err); - this.nav.setRoot(LoginPage); + this.initialPage('personal'); }); this.statusBar.styleDefault(); @@ -63,6 +63,18 @@ export class MyApp { }); } + initialPage(timeline) { + this.storage.get('token').then((val) => { + if (val.length > 1) { + pnut.token = val; + this.nav.setRoot(StreamPage, {stream: timeline}); + } + }).catch(err => { + console.log('ERROR: ' + err); + this.nav.setRoot(LoginPage); + }); + } + openPage(page) { // Reset the content nav to have just this page // we wouldn't want the back button to show in this scenario diff --git a/src/pages/settings/settings.html b/src/pages/settings/settings.html index 8bb524c..b8ba373 100644 --- a/src/pages/settings/settings.html +++ b/src/pages/settings/settings.html @@ -16,6 +16,14 @@ + + Default Timeline + + Home Timeline + Global Timeline + + +

Unified Home

diff --git a/src/pages/settings/settings.ts b/src/pages/settings/settings.ts index a2633b0..7f5d93c 100644 --- a/src/pages/settings/settings.ts +++ b/src/pages/settings/settings.ts @@ -17,12 +17,19 @@ export class SettingsPage { private set_unified: boolean; private set_cc: boolean; + private set_default: string; constructor(public navCtrl: NavController, private storage: Storage, public navParams: NavParams, public events: Events) { } ngAfterViewInit() { + this.storage.get('timeline').then((val) => { + this.set_default = val; + }).catch(err => { + console.log('ERROR: ' +err); + }); + this.storage.get('unified').then((val) => { this.set_unified = val; }).catch(err => { @@ -48,4 +55,8 @@ export class SettingsPage { this.storage.set('cc', this.set_cc); } + updateDefault() { + this.storage.set('timeline', this.set_default); + } + }