adapted to listener-rss v 0.0.3

This commit is contained in:
Amaury 2021-07-06 15:32:47 +02:00
parent 85d38f7939
commit f26ac80aa5

View File

@ -47,16 +47,10 @@ async function register({
}); });
myManager.on('newEntries', (entries: any) => { myManager.on('newEntries', (entries: any) => {
if (firstUpdate) { const datas = listenersDataBinding.get(entries.addressListener);
logger.warn('Premiere update'); if (!datas) return;
firstUpdate = false; logger.warn('Nouvelles entrées détéctées: ' + JSON.stringify(entries));
return;
}
logger.warn(
'Nouvelles baba entrées détéctées: ' + JSON.stringify(entries)
);
}); });
} }
@ -68,13 +62,17 @@ async function addListeners(listenerInput: string) {
logger.warn('Erreur: malformé'); logger.warn('Erreur: malformé');
return; return;
} }
let newListeners = listeners.filter(item => !listenersDataBinding.has(item.address)); let newListeners = listeners.filter(
let removedUrls = Array.from(listenersDataBinding.keys()).filter(url => !listeners.some(listener => listener.url === url)); (item) => !listenersDataBinding.has(item.address)
);
let removedUrls = Array.from(listenersDataBinding.keys()).filter(
(url) => !listeners.some((listener) => listener.address === url)
);
for (const newItem of newListeners) { for (const newItem of newListeners) {
listenersDataBinding.set(newItem.address, { listenersDataBinding.set(newItem.address, {
ChannelId: newItem.ChannelId, ChannelId: newItem.ChannelId,
firstUpdate: newItem.firstUpdate, firstUpdate: true,
address: newItem.address, address: newItem.address,
}); });
} }