Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
comments(story: any) {
if (Ionic.isServer) return;
Ionic.controller('loading', { content: 'fetching comments...' }).then(loading => {
loading.present();
this.fakeFetch(`${this.apiRootUrl}/item/${story.id}`).then((data: { [key: string]: any }) => {
setTimeout(() => {
loading.dismiss().then(() => {
Ionic.controller('modal', { component: 'comments-page', componentProps: { comments: data.comments, storyId: story.id } }).then(modal => {
console.log('modal created');
modal.present().then(() => {
console.log('modal finished transitioning in, commments: ', modal.componentProps.comments);
});
});
});
}, 300);
});
previous() {
if (this.page > 1) {
Ionic.controller('loading', { content: `fetching articles...` }).then(loading => {
loading.present().then(() => {
this.page = this.page--;
console.log(this.page--);
this.fakeFetch(`${this.apiRootUrl}/${this.pageType}?page=${this.page}`).then((data) => {
this.stories = data;
loading.dismiss();
});
});
});
} else {
window.navigator.vibrate(200);
}
next() {
Ionic.controller('loading', { content: `fetching articles...` }).then(loading => {
loading.present().then(() => {
this.page = this.page++;
console.log(this.page++);
this.fakeFetch(`${this.apiRootUrl}/${this.pageType}?page=${this.page}`).then((data) => {
if (data.length !== 0) {
this.stories = data;
}
loading.dismiss();
});
});
});
}
loading.dismiss().then(() => {
Ionic.controller('modal', { component: 'comments-page', componentProps: { comments: data.comments, storyId: story.id } }).then(modal => {
console.log('modal created');
modal.present().then(() => {
console.log('modal finished transitioning in, commments: ', modal.componentProps.comments);
});
});
});
}, 300);
break;
case 'jobs':
this.thirdSelectedClass = true;
this.firstSelectedClass = false;
this.fourthSelectedClass = false;
this.secondSelectedClass = false;
break;
case 'ask':
this.fourthSelectedClass = true;
this.thirdSelectedClass = false;
this.secondSelectedClass = false;
this.firstSelectedClass = false;
break;
}
Ionic.controller('loading', { content: `fetching ${type} articles...` }).then((loading: any) => {
loading.present().then(() => {
this.fakeFetch(`${this.apiRootUrl}/${type}?page=1`).then((data) => {
this.stories = data;
loading.dismiss();
});
this.pageType = type;
});
});
}