Skip to content

Commit

Permalink
Added updateQueue to items
Browse files Browse the repository at this point in the history
  • Loading branch information
builder-247 authored and ChristianDobbie committed Jan 10, 2022
1 parent 22ad0ea commit 47416b5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions svc/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const port = config.PORT || config.ITEMS_PORT;
let discoveredItems;
let bazaarProducts = [];
let itemList = {};
const updateQueue = [];

(async function init() {
try {
Expand Down Expand Up @@ -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) {
Expand All @@ -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' });
Expand Down

0 comments on commit 47416b5

Please sign in to comment.