Skip to content

Commit

Permalink
Fix duplicate sources being added (#33)
Browse files Browse the repository at this point in the history
* Fix duplicate sources being added

* Fix debug log
  • Loading branch information
derme302 authored Jun 8, 2024
1 parent 9322891 commit 751348b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/app/services/sources.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,16 @@ export class SourcesService {
this.newSource.next(feedInfo.url);
}

addSource(feed: IFeedDict) {
this._feedList.push(feed);
console.log('[SourcesService] Adding new feed: ' + feed);
this.storageService.set(STORAGE_FEED_LIST, JSON.stringify(this._feedList));
addSource(newFeed: IFeedDict) {
if (this._feedList.findIndex(feed => feed.url === newFeed.url) === -1) {
this._feedList.push(newFeed);
console.log('[SourcesService] Adding new feed: ' + newFeed.url);
this.storageService.set(STORAGE_FEED_LIST, JSON.stringify(this._feedList));
}
else {
this.presentErrorToast('Feed already exists!');
console.error('[SourcesService] Feed already in feedList: ' + newFeed.url);
}
}

public removeSource(feedUrl: string) {
Expand Down

0 comments on commit 751348b

Please sign in to comment.