From 47416b510a5645872e7c5eaedf2492fe5251bc47 Mon Sep 17 00:00:00 2001 From: builder_247 <14019974+builder-247@users.noreply.github.com> Date: Sun, 1 Aug 2021 01:10:20 +0300 Subject: [PATCH] Added updateQueue to items --- svc/items.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/svc/items.js b/svc/items.js index f40255a5..28f3997b 100644 --- a/svc/items.js +++ b/svc/items.js @@ -16,6 +16,7 @@ const port = config.PORT || config.ITEMS_PORT; let discoveredItems; let bazaarProducts = []; let itemList = {}; +const updateQueue = []; (async function init() { try { @@ -71,7 +72,7 @@ app.post('/', (request, response, _callback) => { let updates = false; items.forEach((item) => { const { id } = item; - if (!discoveredItems.has(id)) { + if (!discoveredItems.has(id) || updateQueue.includes(id)) { updates = true; logger.info(`Found new item ID ${id}`); if (item.texture === null) { @@ -93,9 +94,8 @@ app.post('/', (request, response, _callback) => { app.delete('/:id', (request, response, _callback) => { const { id } = request.params; if (id in itemList) { - logger.info(`Deleting entry for item ${id}`); - delete itemList[id]; - discoveredItems.delete(id); + logger.info(`Adding item ${id} to update queue`); + updateQueue.push(id); updateItemList(); } response.json({ status: 'ok' });