diff --git a/src/listener-rss-aggregator.ts b/src/listener-rss-aggregator.ts index 780ed90..703cf81 100644 --- a/src/listener-rss-aggregator.ts +++ b/src/listener-rss-aggregator.ts @@ -63,26 +63,35 @@ export class ListenerRssAggregator extends EventEmitter { return await ListenerRssAggregator.extractConfig(this.sqliteDb); } + async editConfig( + callback: (config: ListenerRss.Config[]) => ListenerRss.Config[] + ): Promise { + this.stopAll(); + const actualConfig = await this.getAllConfigs(); + this.saveOverride(callback(actualConfig)); + this.startAll(); + } + private addNewListener(info: ListenerRss.Config): ListenerRss { const newListener = new ListenerRss(info); this.listenerMap.set(newListener.address, newListener); newListener.on("update", (obj) => this.emit("update", { - ...obj, - ...{ addressListener: newListener.address }, + items: obj, + addressListener: newListener.address, }) ); newListener.on("newEntries", (obj) => this.emit("newEntries", { - ...obj, - ...{ addressListener: newListener.address }, + items: obj, + addressListener: newListener.address, }) ); newListener.on("error", (err) => this.emit("error", { - ...err, - ...{ addressListener: newListener.address }, + error: err, + addressListener: newListener.address, }) ); diff --git a/tests/index-spec.ts b/tests/index-spec.ts index 4350d80..43857fd 100644 --- a/tests/index-spec.ts +++ b/tests/index-spec.ts @@ -95,7 +95,7 @@ describe("test class ManageListener", function () { await events.once(ml, "update"); //expect expect(updateSpy).to.have.been.calledThrice; - // expect(newEntriesSpy).to.have.been.calledTwice; + // expect(newEntriesSpy).to.have.been.calledTwice; // TODO // here we're testing the second call for the first listener // given