Fix bug where if shop becomes empty last items are not updated in db
This commit is contained in:
@@ -94,11 +94,12 @@ wss.on("connection", (ws) => {
|
||||
|
||||
parsed.shopId = Number(parsed.id);
|
||||
|
||||
if (parsed && Array.isArray(parsed.items) && parsed.shopId != null) {
|
||||
if (parsed && parsed.shopId != null) {
|
||||
const shopId = Number(parsed.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),
|
||||
stock: Number(i.count) || 0,
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user