feat(web-ui): per-network connect toggle, one file for the Networks page - #685
Merged
Conversation
The Networks tab strip carried a single ConnectButton that toggled ED2K and
Kad together, while each tab had its own state-blind Connect/Disconnect
buttons. That mirrored neither the REST API (already symmetric via
POST /networks/{connect,disconnect} with {network: "ed2k"|"kad"|"both"}) nor
amulegui after amule-project#663/amule-project#677, and it meant only the global button reflected the
actual connection state.
Each network tab now owns one state-aware toggle for its own network. Colour
and label follow the real state from the SSE status_changed event — a
red/amber/green plug reading "ED2K: Connected", "Kad: Connecting…" — while the
click performs the opposite action. "connecting" counts as up, so a Kad that is
running-but-not-routing (the backend collapses that into "connecting") stays
stoppable; this matches CKadDlg::OnBnClickedDisconnectKad. There is no
confirmation dialog, matching the buttons it replaces. Disconnecting both
networks at once is no longer offered.
Kad's "Connect from known clients" button is not lost: it issued the same
EC_OP_KAD_START the toggle does, exactly as amulegui's ID_KNOWNNODECONNECT
handler is a bare StartKad() call. "Bootstrap from node" is a genuinely
different operation (EC_OP_KAD_BOOTSTRAP_FROM_IP) and is untouched, as is the
per-row connect that dials one specific server.
The page is now a single view file. servers.js, kad.js, ed2k.js and logs.js
were imported by networks.js and nothing else, so splitting them only bought a
five-request, two-wave waterfall behind the lazy route import in app.js
RouteView — the browser had to parse networks.js before it could discover the
other four. At 410 lines the merged file sits alongside preferences.js (411)
and download-detail.js (429), which are single-file multi-tab views already;
Networks was the only page split up. split-detail.js stays separate, being
shared with Downloads and Shared files.
Merging also let some duplication and dead code go:
- stat() was defined identically in kad.js and ed2k.js; one copy remains, and
the two log panels now share a logBox() helper.
- Three data.ensureStatus() calls in the panels were no-ops. Shell already
calls it unconditionally for every route (app.js) and it is guarded by
statusActive, so Ed2kInfoPanel no longer needs an effect at all.
- NetworkConnectButton lives in the view rather than components.js: it is
Networks-only, and keeping it in components.js would have shipped it
eagerly to every page.
- app.css: the button is now a .btn, so the tool-btn-derived sizing and the
dead .tabs-extra .conn-btn overrides are gone. The state colours and
.tabs-extra itself stay (still used by the Downloads category filters).
- i18n: no new keys — networks_tab_ed2k/_kad and app_connect* already cover
the label. Eight keys left with no reference are removed, and the missing
networks_kad_conn_disabled is added; without it the Kad info panel printed
a raw key string whenever Kad was stopped.
Member
Author
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.


The Networks tab strip carried a single ConnectButton that toggled ED2K and Kad together, while each tab had its own state-blind Connect/Disconnect buttons. That mirrored neither the REST API (already symmetric via POST /networks/{connect,disconnect} with {network: "ed2k"|"kad"|"both"}) nor amulegui after #663/#677, and it meant only the global button reflected the actual connection state.
Each network tab now owns one state-aware toggle for its own network. Colour and label follow the real state from the SSE status_changed event — a red/amber/green plug reading "ED2K: Connected", "Kad: Connecting…" — while the click performs the opposite action. "connecting" counts as up, so a Kad that is running-but-not-routing (the backend collapses that into "connecting") stays stoppable; this matches CKadDlg::OnBnClickedDisconnectKad. There is no confirmation dialog, matching the buttons it replaces. Disconnecting both networks at once is no longer offered.
Kad's "Connect from known clients" button is not lost: it issued the same EC_OP_KAD_START the toggle does, exactly as amulegui's ID_KNOWNNODECONNECT handler is a bare StartKad() call. "Bootstrap from node" is a genuinely different operation (EC_OP_KAD_BOOTSTRAP_FROM_IP) and is untouched, as is the per-row connect that dials one specific server.
The page is now a single view file. servers.js, kad.js, ed2k.js and logs.js were imported by networks.js and nothing else, so splitting them only bought a five-request, two-wave waterfall behind the lazy route import in app.js RouteView — the browser had to parse networks.js before it could discover the other four. At 410 lines the merged file sits alongside preferences.js (411) and download-detail.js (429), which are single-file multi-tab views already; Networks was the only page split up. split-detail.js stays separate, being shared with Downloads and Shared files.
Merging also let some duplication and dead code go: