Skip to content
This repository was archived by the owner on Feb 2, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/feed/feed-news/feed-news.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</div>
<div class="feed-wrapper">
<div class="wrapper feed-results">
<div *ngFor="let item of newsResponse.slice(0,30); let i = index ">
<div *ngFor="let item of newsResponse; let i = index ">
<feed-card [feedItem]="item" [feedIndex]="i"></feed-card>
</div>
</div>
Expand Down
17 changes: 15 additions & 2 deletions src/app/feed/feed-news/feed-news.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Component, OnInit, OnDestroy } from '@angular/core';
import { Store } from '@ngrx/store';
import * as fromRoot from '../../reducers';
import * as newsAction from '../../actions/news';
import { Query } from '../../models/query';
import { Observable } from 'rxjs';

@Component({
selector: 'app-feed-news',
Expand All @@ -12,20 +14,31 @@ import * as newsAction from '../../actions/news';

export class FeedNewsComponent implements OnInit, OnDestroy {
public newsResponse: ApiResponseResult[] = [];
public query: string;
public query$: Observable<Query>;

constructor(
private store: Store<fromRoot.State>
) { }

ngOnInit() {
const texts = [];
this.store.select(fromRoot.getQuery).subscribe(res => this.query = res.displayString);
this.query$ = this.store.select(fromRoot.getQuery);
this.store.select(fromRoot.getNewsResponse).subscribe(v => {
for ( let i = 0; i < v.length; i++ ) {
this.newsResponse.push(v[i]);
if (v[i]['text'].includes(this.query.replace(/\s/g, '').toLowerCase())) {
if (!texts.includes(v[i]['text'].replace(/\s/g, '').toLowerCase())) {
texts.push(v[i]['text'].replace(/\s/g, '').toLowerCase());
this.newsResponse.push(v[i]);
}
}
}
});
}

ngOnDestroy() {
this.store.dispatch(new newsAction.NewsStatusAction(false));
this.newsResponse = null;
}

}
6 changes: 5 additions & 1 deletion src/app/shared/news-org.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export const newsOrgs = [
'CNN',
'nytimes'
'CNNPolitics',
'BBC',
'nytimes',
'guardian',
'toi'
];