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

View file

@ -1,6 +1,7 @@
import { Component, ViewChild, ChangeDetectorRef } from '@angular/core';
import { ViewController, NavController, NavParams, ModalController, Content, ToastController, PopoverController } from 'ionic-angular';
import { ThreadPage } from '../thread/thread';
import { Storage } from '@ionic/storage';
import * as pnut from 'pnut-butter';
@ -26,11 +27,16 @@ export class StreamPage {
fcaller: any;
myUsername: string;
showScrollBtn: boolean = false;
showUnified: boolean;
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));
this.storage.get('unified').then((val) => {
this.showUnified = val;
switch (navParams.data.stream) {
case 'global':
this.title = 'Global';
@ -39,7 +45,8 @@ export class StreamPage {
break;
case 'personal':
this.title = 'Timeline';
this.fetcher = pnut.personal;
console.log(this.showUnified);
this.fetcher = this.showUnified ? pnut.unified : pnut.personal;
this.fetchPosts();
break;
case 'mentions':
@ -53,6 +60,12 @@ export class StreamPage {
this.fetchMyPosts();
break;
}
}).catch(err => {
console.log('ERROR: ' + err);
});
pnut.user('me').then(res => {
this.myUsername = res.data.username;
}).catch(err => {