Fix bug where if shop becomes empty last items are not updated in db
This commit is contained in:
parent
eb028a8fbf
commit
f8ebb620eb
5
server.js
Normal file → Executable file
5
server.js
Normal file → Executable file
@ -94,11 +94,12 @@ wss.on("connection", (ws) => {
|
|||||||
|
|
||||||
parsed.shopId = Number(parsed.id);
|
parsed.shopId = Number(parsed.id);
|
||||||
|
|
||||||
if (parsed && Array.isArray(parsed.items) && parsed.shopId != null) {
|
if (parsed && parsed.shopId != null) {
|
||||||
const shopId = Number(parsed.shopId);
|
const shopId = Number(parsed.shopId);
|
||||||
ws._shopId = shopId;
|
ws._shopId = shopId;
|
||||||
|
|
||||||
const items = parsed.items.map((i) => ({
|
const rawItems = Array.isArray(parsed.items) ? parsed.items : [];
|
||||||
|
const items = rawItems.map((i) => ({
|
||||||
item_name: String(i.name),
|
item_name: String(i.name),
|
||||||
stock: Number(i.count) || 0,
|
stock: Number(i.count) || 0,
|
||||||
}));
|
}));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user