/**
 * Boost feed for discovery module.
 * Plugs into feeds service.
 */ import { Component , OnInit } from '@angular/core' ; import { Observable , BehaviorSubject } from 'rxjs' ; import { ActivatedRoute } from '@angular/router' ; import { FeedsService } from '../../../common/services/feeds.service' ; @ Component ( { selector : 'm-discovery__boostFeed' , templateUrl : './boost-feed.component.html' , providers : [ FeedsService ] , } ) export class DiscoveryBoostFeedComponent implements OnInit { constructor ( public route , private feedsService ) { } async ngOnInit ( ) { await this . load ( ) ; } returns { Observable < BehaviorSubject < Object > [ ] > } public get feed$ ( ) : Observable < BehaviorSubject < Object > [ ] > { return this . feedsService . feed ; } returns { Observable < boolean > } public get hasMore$ ( ) : Observable < boolean > { return this . feedsService . hasMore ; } returns { Observable < boolean > } public get inProgress$ ( ) : Observable < boolean > { return this . feedsService . inProgress ; } param { boolean } refresh return { Promise < boolean > } private async load ( refresh = false ) { try { if ( refresh ) { this . feedsService . clear ( ) ; } this . feedsService . setEndpoint ( 'api/v2/boost/feed' ) . setParams ( { boostfeed : true , force_boost_enabled : true , } ) . setLimit ( 6 ) . setOffset ( 0 ) . fetch ( ) ; return true ; } catch ( e ) { return false ; } } returns { Promise < void > } public async loadNext ( ) { if ( this . feedsService . canFetchMore && ! this . feedsService . inProgress . getValue ( ) && this . feedsService . offset . getValue ( ) ) { this . feedsService . fetch ( ) ; } this . feedsService . loadMore ( ) ; } }