Update feed list on delete
This commit is contained in:
parent
5fccad9b3b
commit
af628a1727
@ -16,9 +16,7 @@ export class EinstellungenComponent implements OnInit {
|
||||
|
||||
icon;
|
||||
|
||||
feeds: Observable<IFeed[]>;
|
||||
|
||||
mySubscription;
|
||||
feeds: IFeed[];
|
||||
|
||||
constructor(private http: HttpClient,
|
||||
private _snackbar: MatSnackBar,
|
||||
@ -28,17 +26,7 @@ export class EinstellungenComponent implements OnInit {
|
||||
private _router: Router) {
|
||||
this.icon = 'assets/logo.svg';
|
||||
this._router.routeReuseStrategy.shouldReuseRoute = () => false;
|
||||
this.mySubscription = this._router.events.subscribe((event) => {
|
||||
if (event instanceof NavigationEnd) {
|
||||
// Trick the Router into believing it's last link wasn't previously loaded
|
||||
this._router.navigated = false;
|
||||
}
|
||||
});
|
||||
this._feedService.getFeeds().subscribe(
|
||||
(data: any) => {
|
||||
this.feeds = data;
|
||||
}
|
||||
);
|
||||
this._feedService.getFeeds().toPromise().then(data => this.feeds = data).catch(err => this._logger.error(err));
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
@ -48,12 +36,12 @@ export class EinstellungenComponent implements OnInit {
|
||||
this.http.delete('http://127.0.0.1:8000/feeds/' + id + '/').subscribe(
|
||||
() => {
|
||||
this._snackbar.open('Feed erfolgreich gelöscht!', 'Schließen', {duration: 3000});
|
||||
this.feeds = this.feeds.filter(feed => feed.id !== id);
|
||||
},
|
||||
err => {
|
||||
this._logger.error(err);
|
||||
return throwError(err);
|
||||
}
|
||||
);
|
||||
this._router.navigate([this._router.url]);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user