diff --git a/TradeSkillMaster_AuctionDB/Modules/ChannelSync.lua b/TradeSkillMaster_AuctionDB/Modules/ChannelSync.lua index cb1ccc9..76604bf 100644 --- a/TradeSkillMaster_AuctionDB/Modules/ChannelSync.lua +++ b/TradeSkillMaster_AuctionDB/Modules/ChannelSync.lua @@ -141,20 +141,26 @@ function ChannelSync:BroadcastScanData(scanType) end end -local function MergeIncomingData(payload) +local function MergeIncomingData(payload, sender) if type(payload) ~= "table" or type(payload.scanData) ~= "string" then return end local incoming = {} TSM:Deserialize(payload.scanData, incoming, true) + local updated = 0 + local lastItemID for itemID, data in pairs(incoming) do local existing = TSM.data[itemID] if existing then TSM:DecodeItemData(itemID) if data.lastScan and (not existing.lastScan or data.lastScan > existing.lastScan) then TSM.data[itemID] = data + updated = updated + 1 + lastItemID = itemID end else TSM.data[itemID] = data + updated = updated + 1 + lastItemID = itemID end end @@ -163,6 +169,15 @@ local function MergeIncomingData(payload) end TSM:Serialize() + + if updated > 0 and sender then + if updated == 1 and lastItemID then + local link = select(2, GetItemInfo(lastItemID)) or ("item:" .. tostring(lastItemID)) + TSM:Printf("AuctionDB updated %s from %s.", link, sender) + else + TSM:Printf("AuctionDB updated %d items from %s.", updated, sender) + end + end end function ChannelSync:OnChannelMessage(_, msg, source, _, _, _, _, _, channelName) @@ -211,7 +226,7 @@ function ChannelSync:OnChannelMessage(_, msg, source, _, _, _, _, _, channelName local payload = DecodePayload(table.concat(parts)) if not payload then return end - MergeIncomingData(payload) + MergeIncomingData(payload, source) end function ChannelSync:SendQueueThread()