Skip to content

Commit

Permalink
Publish listings/remove before listings/add (#1347)
Browse files Browse the repository at this point in the history
  • Loading branch information
karashiiro authored Jul 24, 2024
1 parent 60d613a commit c6bffd9
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,41 +148,41 @@ private async Task PublishListingsToMessageBus(IList<Listing> listings, int worl
var addedListings = listings.Where(l => !oldListings.Contains(l)).ToList();
var removedListings = oldListings.Where(l => !listings.Contains(l)).ToList();

if (addedListings.Count > 0)
if (removedListings.Count > 0)
{
try
{
await _bus.Publish(new ListingsAdd
await _bus.Publish(new ListingsRemove
{
WorldId = worldId,
ItemId = itemId,
Listings = addedListings
Listings = removedListings
.Select(Util.ListingToView)
.ToList(),
}, cancellationToken);
}
catch (Exception e)
{
_logger.LogError(e, "Failed to publish ListingsAdd event");
_logger.LogError(e, "Failed to publish ListingsRemove event");
}
}

if (removedListings.Count > 0)
if (addedListings.Count > 0)
{
try
{
await _bus.Publish(new ListingsRemove
await _bus.Publish(new ListingsAdd
{
WorldId = worldId,
ItemId = itemId,
Listings = removedListings
Listings = addedListings
.Select(Util.ListingToView)
.ToList(),
}, cancellationToken);
}
catch (Exception e)
{
_logger.LogError(e, "Failed to publish ListingsRemove event");
_logger.LogError(e, "Failed to publish ListingsAdd event");
}
}
}
Expand Down

0 comments on commit c6bffd9

Please sign in to comment.