Change signature of customFields and make ListenerRSSInfos properties ro

This commit is contained in:
Florent
2021-02-14 17:37:03 +01:00
committed by Florent F
parent f8c9eb7d35
commit 5c430b61b1
3 changed files with 37 additions and 41 deletions

View File

@ -1,6 +1,6 @@
export interface ListenerRSSInfos {
name: string; // name of the listener
address: string; // feed's address
timeloop?: number; // update time RSS feed
customfields?: [string, string | [string, string]][]; // rss fields custom
readonly name: string; // name of the listener
readonly address: string; // feed's address
readonly timeloop?: number; // update time RSS feed
readonly customfields?: { [key: string]: string | string[] }; // rss fields custom
}

View File

@ -7,7 +7,7 @@ export class ListenerRss {
name: string = "";
address: string = "";
timeloop: number = DEFAULT_TIMELOOP; // time in seconds
customfields?: [string, string | [string, string]][];
customfields?: { [key: string]: string[] | string };
// private fields
parser: Parser | undefined = undefined;
@ -24,8 +24,8 @@ export class ListenerRss {
this.customfields !== undefined
? {
customFields: {
item: this.customfields.map((elt) => {
return Array.isArray(elt[1]) ? elt[1][0] : elt[1];
item: Object.entries(this.customfields).map(([, value]) => {
return Array.isArray(value[1]) ? value[1][0] : value[1];
}),
},
}
@ -39,8 +39,7 @@ export class ListenerRss {
this.address = infos.address;
this.timeloop =
infos.timeloop === undefined ? DEFAULT_TIMELOOP : infos.timeloop;
this.customfields =
infos.customfields === undefined ? undefined : infos.customfields;
this.customfields = infos.customfields;
}
fetchRSS(): any {