Skip to content
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

Use Vuex to manage error modal #1225

Merged
merged 1 commit into from
Feb 29, 2024
Merged

Use Vuex to manage error modal #1225

merged 1 commit into from
Feb 29, 2024

Conversation

anttimaki
Copy link
Collaborator

  • Main benefit is that emitted errors no longer need to bubble all the way to the App.vue to get shown. This should prevent situations where refactoring components distrupts the emit chain and leaves the error unshown
  • Refactors the modal to a single standalone component
  • Fixes the odd naming where R2Error's "name" was stored in variable called "message", and "message" was stored in "stack" variable
  • Unifies some logged messages from "name\n-> message" format to "[name]: message" format

@anttimaki
Copy link
Collaborator Author

  • Will probably conflict with all other changes, so let me know when it's okay to merge this and I can take care of conflicts
  • Requires changes to TSMM, current avaialble as a draft PR

Copy link
Collaborator

@MythicManiac MythicManiac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't finished reviewing yet but immediate thought is (and has been for a few other PRs already): we should stop expanding the ModalsModule.ts to become a mega-monolith of 329 different modal use cases, most of the modals have nothing to do with each other so it's a bit silly to store their state in the same module.

I don't think it should be considered a blocker for this PR necessarily, but I don't like the trend I've seen with how the code has evolved in that module over time. It's not even namespaced so it could easily lead to unintentional conflicts in the future at this rate.

Copy link
Collaborator

@MythicManiac MythicManiac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say the improvement suggestions I left are more than just nitpicks, but I also don't consider them a blocker for merging as they could easily be addressed as separate PRs.

So overall LGTM

state: (): State => ({
downloadModModalMod: null,
errorModalError: null,
isCategoryFilterModalOpen: false,
isDownloadModModalOpen: false,
isErrorModalOpen: false,
isGameRunningModalOpen: false,
}),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the benefit in tracking the error state & modal open state separately? as far as I can tell those two fields are supposed to always be in sync anyway, could we not just check if the error exists? would eliminate any possibility of the two desyncing & potentially leading to weird UI bugs down the line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to stay consistent with downloadModModalMod and disableModModalMod (not pictured). But I agree, it's unnecessary.

@@ -38,6 +55,21 @@ export default {
state.isDownloadModModalOpen = true;
},

openErrorModal: function(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this does more than just opens the modal so the name could be a bit misleading, would it make sense to just call this something like handleError?

- Main benefit is that emitted errors no longer need to bubble all the
  way to the App.vue to get shown. This should prevent situations where
  refactoring components distrupts the emit chain and leaves the error
  unshown
- Refactors the modal to a single standalone component
- Fixes the odd naming where R2Error's "name" was stored in variable
  called "message", and "message" was stored in "stack" variable
- Unifies some logged messages from "name\n-> message" format to
  "[name]: message" format
@anttimaki
Copy link
Collaborator Author

@MythicManiac do you want to review again or am I good to merge?

Comment on lines +32 to +36
if (error instanceof R2Error) {
LoggerProvider.instance.Log(LogSeverity.ERROR, `[${error.name}]: ${error.message}`);
} else {
const msg = error.logMessage || `[${error.error.name}]: ${error.error.message}`;
LoggerProvider.instance.Log(error.severity, msg);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is brilliant 👍

@MythicManiac MythicManiac merged commit c5238fe into develop Feb 29, 2024
7 checks passed
@MythicManiac MythicManiac deleted the vuex-error-modal branch February 29, 2024 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants