added setting for unified timeline, issue #29 and #31

This commit is contained in:
Morgan McMillian 2017-08-04 13:22:13 -07:00
parent e9176adb80
commit b11ea8e215
2 changed files with 41 additions and 27 deletions

View file

@ -57,9 +57,9 @@ export class MyApp {
this.statusBar.styleDefault(); this.statusBar.styleDefault();
this.splashScreen.hide(); this.splashScreen.hide();
console.log('---'); // console.log('---');
console.log(this.device.platform); // console.log(this.device.platform);
console.log('---'); // console.log('---');
}); });
} }
@ -67,7 +67,8 @@ export class MyApp {
// Reset the content nav to have just this page // Reset the content nav to have just this page
// we wouldn't want the back button to show in this scenario // we wouldn't want the back button to show in this scenario
if (page.title === 'Logout') { if (page.title === 'Logout') {
this.storage.remove('token'); // this.storage.remove('token');
this.storage.clear();
this.nav.setRoot(LoginPage); this.nav.setRoot(LoginPage);
} else if (page.title === 'Settings') { } else if (page.title === 'Settings') {
this.nav.push(page.component, page.params); this.nav.push(page.component, page.params);

View file

@ -1,6 +1,7 @@
import { Component, ViewChild, ChangeDetectorRef } from '@angular/core'; import { Component, ViewChild, ChangeDetectorRef } from '@angular/core';
import { ViewController, NavController, NavParams, ModalController, Content, ToastController, PopoverController } from 'ionic-angular'; import { ViewController, NavController, NavParams, ModalController, Content, ToastController, PopoverController } from 'ionic-angular';
import { ThreadPage } from '../thread/thread'; import { ThreadPage } from '../thread/thread';
import { Storage } from '@ionic/storage';
import * as pnut from 'pnut-butter'; import * as pnut from 'pnut-butter';
@ -26,33 +27,45 @@ export class StreamPage {
fcaller: any; fcaller: any;
myUsername: string; myUsername: string;
showScrollBtn: boolean = false; showScrollBtn: boolean = false;
showUnified: boolean;
constructor(public navCtrl: NavController, public navParams: NavParams, public modalCtrl: ModalController, constructor(public navCtrl: NavController, public navParams: NavParams, public modalCtrl: ModalController,
private changeDetectorRef: ChangeDetectorRef, public toastCtrl: ToastController, public popoverCtrl: PopoverController) { private changeDetectorRef: ChangeDetectorRef, public toastCtrl: ToastController, private storage: Storage,
public popoverCtrl: PopoverController) {
// console.log(JSON.stringify(navParams)); // console.log(JSON.stringify(navParams));
switch (navParams.data.stream) { this.storage.get('unified').then((val) => {
case 'global': this.showUnified = val;
this.title = 'Global';
this.fetcher = pnut.global; switch (navParams.data.stream) {
this.fetchPosts(); case 'global':
break; this.title = 'Global';
case 'personal': this.fetcher = pnut.global;
this.title = 'Timeline'; this.fetchPosts();
this.fetcher = pnut.personal; break;
this.fetchPosts(); case 'personal':
break; this.title = 'Timeline';
case 'mentions': console.log(this.showUnified);
this.title = 'Mentions'; this.fetcher = this.showUnified ? pnut.unified : pnut.personal;
this.fetcher = pnut.mentions; this.fetchPosts();
this.fetchMyPosts(); break;
break; case 'mentions':
case 'bookmarks': this.title = 'Mentions';
this.title = 'Bookmarks'; this.fetcher = pnut.mentions;
this.fetcher = pnut.bookmarks; this.fetchMyPosts();
this.fetchMyPosts(); break;
break; case 'bookmarks':
} this.title = 'Bookmarks';
this.fetcher = pnut.bookmarks;
this.fetchMyPosts();
break;
}
}).catch(err => {
console.log('ERROR: ' + err);
});
pnut.user('me').then(res => { pnut.user('me').then(res => {
this.myUsername = res.data.username; this.myUsername = res.data.username;
}).catch(err => { }).catch(err => {