private some fields and now newEntries is called only for the second update
This commit is contained in:
parent
9c034a6100
commit
fcf7c24b86
|
@ -23,9 +23,10 @@ class ListenerRss extends EventEmitter {
|
|||
customfields?: { [key: string]: string[] | string };
|
||||
|
||||
// private fields
|
||||
parser: Parser;
|
||||
loopRunning: boolean = false;
|
||||
lastEntriesLinks: string[] = [];
|
||||
private parser: Parser;
|
||||
private loopRunning: boolean = false;
|
||||
private lastEntriesLinks: string[] = [];
|
||||
private firstUpdate = true;
|
||||
|
||||
/**
|
||||
* @brief constructor
|
||||
|
@ -89,10 +90,12 @@ class ListenerRss extends EventEmitter {
|
|||
!this.lastEntriesLinks.includes(item.link)
|
||||
);
|
||||
|
||||
if (newEntries.length !== 0) {
|
||||
this.emit("newEntries", newEntries);
|
||||
}
|
||||
this.lastEntriesLinks = updatedEntriesLinks;
|
||||
|
||||
if (this.firstUpdate && newEntries.length !== 0)
|
||||
this.emit("newEntries", newEntries);
|
||||
|
||||
this.firstUpdate = false;
|
||||
})
|
||||
.catch((err) => this.emit("error", err))
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user