caravan: fix doubled pending value and lost marks across filter views - #1620
Open
Alistair-Afton wants to merge 1 commit into
Open
Alistair-Afton wants to merge 1 commit into
Alistair-Afton wants to merge 1 commit into
Conversation
Each "bring goods to depot" filter combination (grouped x inside containers) cached its own copy of choice state. Rebuilding a combo added the selected values to the pending total again, doubling the displayed value, and marks made in one view were invisible in the others, so dismissing the modal silently dropped them. Keep a shared set of explicit marks on the MoveGoods widget, derive each cached view's pending flags from it, recompute the pending total once per scan instead of accumulating it, and commit every explicit mark on dismiss regardless of which view is active.
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.
Summary
Fixes DFHack/dfhack#5829
The movegoods overlay caches a separate copy of choice state for each filter combination (grouped x inside containers). Rebuilding a combination added all selected values to the pending total again, which doubled the displayed "total value of items marked for trade". Marks made in one view were also invisible in the others, and dismissing the modal only committed the currently active view, so marks were silently lost.
Marked state is now a shared set of explicit user decisions on the widget. Each cached view derives its pending flags from it, the pending total is recomputed once per scan, and dismiss commits every explicit mark regardless of the active view.
Testing
In game with a fort and trade depot: instantiated the modal and exercised all four filter combinations. The pending total stays constant instead of doubling. Marks made in the ungrouped view remain visible in the grouped and inside containers views, and dismissing while viewing a different filter still creates the BringItemToDepot job. Unmarking and remarking adjusts the total correctly, and icons update on toggled items.