Added editConfig Function
This commit is contained in:
parent
14b2df7bdc
commit
b0811ea505
|
@ -63,26 +63,35 @@ export class ListenerRssAggregator extends EventEmitter {
|
|||
return await ListenerRssAggregator.extractConfig(this.sqliteDb);
|
||||
}
|
||||
|
||||
async editConfig(
|
||||
callback: (config: ListenerRss.Config[]) => ListenerRss.Config[]
|
||||
): Promise<void> {
|
||||
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,
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user