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