Commit e3143161 authored by Mark Harding's avatar Mark Harding

(feat): refresh newsfeed on renavigation

parent 1790d347
No related merge requests found
Pipeline #73597753 running with stages
import { Component, Injector, SkipSelf, ViewChild } from '@angular/core';
import { Subscription, BehaviorSubject } from 'rxjs';
import { filter } from 'rxjs/operators';
import { ActivatedRoute, Router } from '@angular/router';
import { ActivatedRoute, Router, RouterEvent, NavigationEnd } from '@angular/router';
import { Client, Upload } from '../../../services/api';
import { MindsTitle } from '../../../services/ux/title';
......@@ -52,6 +53,7 @@ export class NewsfeedSubscribedComponent {
paramsSubscription: Subscription;
reloadFeedSubscription: Subscription;
routerSubscription: Subscription;
@ViewChild('poster', { static: true }) private poster: PosterComponent;
......@@ -79,6 +81,16 @@ export class NewsfeedSubscribedComponent {
}
ngOnInit() {
this.routerSubscription = this.router.events.pipe(
filter((event: RouterEvent) => event instanceof NavigationEnd)
).subscribe(() => {
this.showBoostRotator = false;
this.load(true, true);
setTimeout(() => {
this.showBoostRotator = true;
}, 100);
});
this.reloadFeedSubscription = this.newsfeedService.onReloadFeed.subscribe(() => {
this.load(true, true);
});
......@@ -92,14 +104,6 @@ export class NewsfeedSubscribedComponent {
}
this.newUserPromo = !!params['newUser'];
if (params['ts']) {
this.showBoostRotator = false;
this.load(true);
setTimeout(() => {
this.showBoostRotator = true;
}, 300);
}
});
this.context.set('activity');
......@@ -108,6 +112,7 @@ export class NewsfeedSubscribedComponent {
ngOnDestroy() {
this.paramsSubscription.unsubscribe();
this.reloadFeedSubscription.unsubscribe();
this.routerSubscription.unsubscribe();
}
load(refresh: boolean = false, forceSync: boolean = false) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment