Fix shop sign [stock color] desync on load (stuck “out of stock” red)#41
Merged
Fix shop sign [stock color] desync on load (stuck “out of stock” red)#41
[stock color] desync on load (stuck “out of stock” red)#41Conversation
Build Completed Successfully! 🎉Version: 1.10.2-696d211 Download Build |
Coverage Report
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Users were reporting shops having stock but displaying red as out of stock (seems to just be a visual issue) as they can still buy from them
(AI Generated description)
Problem
Some shops display the
[shop]line inout_of_stockcolor (red) even when they have stock and transactions still succeed. Hover info correctly shows stock, but the sign’s color can remain stale after startup/load.Root Cause
stock.stockwas restored from disk, and laterload()could skip refreshing the sign ifupdateStock()recomputed the same value (no “stock change” → no forced sign update, whileupdateSign()is gated bysignLinesRequireRefresh).Fix
ShopHandler.loadShopsFromConfig(), applysetStockOnLoad(stock)beforesetItemStack()/setSecondaryItemStack()to avoid early sign rendering with defaultstock=0.AbstractShop.load(), setsignLinesRequireRefresh = trueimmediately beforeupdateStock()so the sign is refreshed even whenoldStock == newStock.Tests
ShopSignStockColorDesyncOnLoadTestto reproduce the stuck-red sign scenario and verify the sign updates to in-stock color afterload()whenstock > 0.mvn -pl core testsuccessfully.Risk / Compatibility
Changes are limited to shop load initialization and sign refresh behavior; no transaction logic changes.