refactor(web-ui): give the row key one owner - #1286
Conversation
|
Verified the invariant closes. Checked the two ways this could break. Nothing still references the removed The Known-tab case is fine: a known row never gains an Scope looks right too. The other views key on a single field, so even where the key is derived twice there is no fallback expression to diverge; this was the only compound one. No findings from me. Assigning @ngosang, who owns Web UI development, and leaving the merge to him. |
clients.js and client-table.js each carried the same row-identity expression, byte for byte, and had to agree: clients.js keyed its selection with its copy while ClientTable matched selectedKey with its own. A divergence would have stopped the selected-row highlight from ever appearing, with no error and no test to catch it. VirtualTable already receives that function as rowKey and already calls it for reconciliation; it just did not pass the result to the click handler. It does now, so clients.js carries a key it never derives and ClientTable is the only module that knows what identifies a row. The argument is appended, so downloads.js and shared.js -- which declare (d, e) and (s, e) -- ignore it and are untouched. Refs amule-org#1285
2865a41 to
e35f92a
Compare
Closes #1285.
clients.js:29andclient-table.js:277each carried the same row-identityexpression, byte for byte:
They had to agree.
clients.jskeyed its selection state with its copy;ClientTablematchedselectedKeyagainst its own and also used it as therowKeyfor reconciliation. A divergence would have stopped the selected-rowhighlight from ever appearing — no error, no exception, no test, just a
highlight that quietly never shows.
Why the key moves
ClientTablealready hands its function to the generic table asrowKey(
client-table.js:287), andVirtualTablealready calls it for the row'skey(
table.js:265). It just did not pass the result to the click handler, and thatwas the only reason the panel had to derive it a second time.
Now it does, so
clients.jscarries a key it never interprets andclient-table.jsis the only module that knows what identifies a row. The valueused for reconciliation, for
rowClass, and for the selection is the same oneby construction rather than by two expressions happening to match.
Scope
table.jscomputes the key once per row rather than twice, and appends it tothe handler call. Appending is backward compatible:
downloads.js:40andshared.js:39declare(d, e)and(s, e), so they ignore a third argumentand are untouched.
client-table.jsis unchanged and itskeystays unexported.Verification
ecid; Known rows have none, becauseWriteKnownClientObjectnever emits one, so they key onuser_hash. Bothpaths were exercised, including the click-again-to-close toggle and the
switch between two rows.
rowKeyis a required prop —table.js:265already called it unguarded — sono caller can reach the new argument without one.
Not covered: the web UI has no JS test harness, so this is verified by reading
the call chain and exercising the key logic in isolation, not by a test.
check-i18n.mjspasses and all five touched or dependent modules parse undernode --check; neither exercises the change.