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