Added setting for default timeline, issue #40

This commit is contained in:
Morgan McMillian 2017-09-05 20:50:16 -07:00
parent d0269b11a3
commit db9cd43d58
3 changed files with 36 additions and 5 deletions

View file

@ -45,14 +45,14 @@ export class MyApp {
// Okay, so the platform is ready and our plugins are available. // Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need. // 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) { if (val.length > 1) {
pnut.token = val; this.initialPage(val);
this.nav.setRoot(StreamPage, {stream: 'personal'}); } else {
console.log('ERR WHUT?');
} }
}).catch(err => { }).catch(err => {
console.log('ERROR: ' + err); this.initialPage('personal');
this.nav.setRoot(LoginPage);
}); });
this.statusBar.styleDefault(); 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) { openPage(page) {
// 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

View file

@ -16,6 +16,14 @@
<ion-content overflow-scroll=”true”> <ion-content overflow-scroll=”true”>
<ion-list> <ion-list>
<ion-item>
<ion-label>Default Timeline</ion-label>
<ion-select [(ngModel)]="set_default" (ionChange)="updateDefault()" interface="popover">
<ion-option value="personal">Home Timeline</ion-option>
<ion-option value="global">Global Timeline</ion-option>
</ion-select>
</ion-item>
<ion-item> <ion-item>
<ion-label> <ion-label>
<h2>Unified Home</h2> <h2>Unified Home</h2>

View file

@ -17,12 +17,19 @@ export class SettingsPage {
private set_unified: boolean; private set_unified: boolean;
private set_cc: boolean; private set_cc: boolean;
private set_default: string;
constructor(public navCtrl: NavController, private storage: Storage, public navParams: NavParams, constructor(public navCtrl: NavController, private storage: Storage, public navParams: NavParams,
public events: Events) { public events: Events) {
} }
ngAfterViewInit() { ngAfterViewInit() {
this.storage.get('timeline').then((val) => {
this.set_default = val;
}).catch(err => {
console.log('ERROR: ' +err);
});
this.storage.get('unified').then((val) => { this.storage.get('unified').then((val) => {
this.set_unified = val; this.set_unified = val;
}).catch(err => { }).catch(err => {
@ -48,4 +55,8 @@ export class SettingsPage {
this.storage.set('cc', this.set_cc); this.storage.set('cc', this.set_cc);
} }
updateDefault() {
this.storage.set('timeline', this.set_default);
}
} }