Skip to content

Commit

Permalink
[web-app] unsubscribe from feed fetch when the feed panel tab changes…
Browse files Browse the repository at this point in the history
… to prevent showing content of incorrect feed
  • Loading branch information
restjohn committed Mar 11, 2024
1 parent 698f397 commit 1f6d791
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion web-app/src/app/feed/feed-list/feed-list.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { Feed, FeedService } from '@ngageoint/mage.web-core-lib/feed';
import { Feature } from 'geojson';
import { Subscription } from 'rxjs'

@Component({
selector: 'feed-list',
Expand All @@ -11,13 +12,15 @@ export class FeedListComponent implements OnChanges {
@Input() feed: Feed

items: Array<Feature> = []
feedSubscription: Subscription | null = null

constructor(private feedService: FeedService) {}

ngOnChanges(changes: SimpleChanges): void {
const feed: Feed = changes.feed.currentValue;
this.feedSubscription?.unsubscribe()
if (feed) {
this.feedService.feedItems(feed.id).subscribe(items => {
this.feedSubscription = this.feedService.feedItems(feed.id).subscribe(items => {
this.items = items;
});
}
Expand Down

0 comments on commit 1f6d791

Please sign in to comment.