mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 07:54:42 +00:00
Move various state computations from the UI to the NodeModel #434
No reviewers
Labels
No labels
Android
Bug
Build system
Design suggestion
Doc
Needs design review
Needs rebase
Stage
UX
Up for grabs
Upstream
Wallet
duplicate
enhancement
good first issue
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin-core/gui-qml!434
Loading…
Reference in a new issue
No description provided.
Delete branch "compute-states-in-nodemodel"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
To enforce clear seperation between the UI and the backend, as well as to begin the removal of any js functions, this shifts the following string construction and state computations from the UI into the NodeModel itself (which is where it belongs)
These strings and states are now available and reusable wherever they may be needed, instead of needing to be computed by every file which needs that information.
As a rule, the UI should have no computation of any sorts outside of things related to UI specific ideas such as color or sizing; any other computation needs to be strictly done in our backend.
cr ACK
It looks much cleaner. Regarding the formatting, as discussed offline, I'd take it out from the NodeModel, I think it's not its responsibility and not related with business logic and the node itself, I'd create a separate object to make the formatting.
I wanted to expand on my previous review and provide additional details, especially since we discussed in our call that more context and actionable feedback would be helpful.
Why this is important:
Counterpoint: While we were advised to avoid generalizing for single-use cases, I believe this is an exception for two reasons:
Specific Suggestions:
Refactor the large setFormattedRemainingSyncTime function into a TimeFormatter class or similar utility.
Snippet code sample.
Modify NodeModel to delegate formatting logic to NodeFormatter:
Use a handler pattern to simplify the chain of if conditions.
Snippet code sample.
Please remove trailing spaces to fix the CI lint job:
Due to the author's inactivity, closing and labeling "Up for grabs".