-
Notifications
You must be signed in to change notification settings - Fork 233
Separate mod importing business logic from the UI component #1445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Moved a couple of functions away from the ui component, still more stuff to do. You can review the progress to check if the approach is OK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- It was discussed that this should be one commit (or PR) per moved method so I'm disappointed to see these changed lumped together. Not a blocker though.
- Blocker: moving the business logic to ProfilesMixin.vue still means they're in a vue component. The point of the task was to not have these in vue components anymore, but rather on Vuex or separate utils files, depending on how much they depend on the Vuex state
- Blocker: at least on my local env, importing a profile no longer shows the progress modal. Everything happens on the background. Use can change the selected profile while import is in progress
- Blocker: some of the new methods are missing types for arguments
- Remember to clean out unused imports when moving code out of files (well, always when making changes, I guess)
- Having the
createProfileClicked
methods receive the profile name as an argument seems a bit confusing when all other places access it throughthis.newProfileName
d2b78e0
to
cc62082
Compare
cc62082
to
a4be2da
Compare
Didn't test/review my changes very deeply yet, but shouldn't be any big bugs (probably jinxing myself). |
So this is sort of an intuition thing which might be partly triggered by the all-things-at-once approach, but I don't think this is the way we want to refactor this either. Some more concrete things:
Generally speaking, as a rule of thumb I've liked to have component methods to be something like this when feasible: try {
ProfileUtils.doOneThing();
// Possible more ProfileUtils calls if they share error handling
} catch (e) {
this.$store.commit('error/handleError', R2Error.fromThrownValue(e));
} Also generally speaking each helper function should take a limited number of "simple" parameters (string, ThunderstoreMod) and return "simple" values. Callback functions make sometimes sense but personally I'd avoid other functions if it can be done easily. Anyway, I agree that this component is a bit complex one to be the first exercise. I would suggest we abandon this branch and start from the scratch. We'd start from the easy cases the to get the ball rolling and worry about the more complex stuff later. Sometimes cleaning the easy stuff away reduces the complexity and makes the rest easier. Even if it doesn't, we can then think about the hard parts separately, which is cognitively easier than trying to handle everything at once. On a concrete level my suggestion would be:
If you agree with the above, I'd suggest the first three PRs would be:
We'll figure out the next steps when that time comes. |
It was decided to redo this in smaller parts. |
No description provided.