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

Refactor Rename Profile Modal by separating it from Profiles.vue #1328

Merged
merged 5 commits into from
Jun 11, 2024

Conversation

VilppeRiskidev
Copy link
Collaborator

  • RenameProfileModal has been separated from Profiles.vue
  • Actions renameProfile and updateProfileList have been added to ProfilesModule
  • Old profile renaming functionality has been removed from Profiles page

@VilppeRiskidev VilppeRiskidev self-assigned this May 20, 2024
@VilppeRiskidev VilppeRiskidev force-pushed the rename-profile-modal-refactor branch 2 times, most recently from d502c3b to 211998f Compare May 20, 2024 12:16
Copy link
Collaborator

@anttimaki anttimaki left a comment

Choose a reason for hiding this comment

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

Quite many comments but mostly minor ones. Also they're all new ones, so good job picking up the lessons from the previous PR!

Bonus cookie points if you can make the the input submit the changes by pressing enter instead of having to click the submit button with mouse.

src/components/profiles-modals/RenameProfileModal.vue Outdated Show resolved Hide resolved
src/components/profiles-modals/RenameProfileModal.vue Outdated Show resolved Hide resolved
src/components/profiles-modals/RenameProfileModal.vue Outdated Show resolved Hide resolved
src/components/profiles-modals/RenameProfileModal.vue Outdated Show resolved Hide resolved
<template v-slot:body>
<p>This profile will store its own mods independently from other profiles.</p>

<input class="input" v-model="newProfileName" ref="profileNameInput" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

The ref attribute was part of these changes and most likely shouldn't be present in this standalone component. Would HTML's autofocus attribute work here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

doesn't work for some reason, I guess it'd have to be a <dialog>

src/store/modules/ModalsModule.ts Outdated Show resolved Hide resolved
src/store/modules/ProfilesModule.ts Outdated Show resolved Hide resolved
src/store/modules/ProfilesModule.ts Outdated Show resolved Hide resolved
components: {ModalCard}
})
export default class RenameProfileModal extends Vue {
private newProfileName: string = '';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This still has a bug, where the newprofilename is empty when the modal is first opened (for example coming from the game selection). Doing private newProfileName: string = this.$store.state.profile.activeProfile.getProfileName(); doesn't work either. I'll look into this, but if you can immediately think of a solution feel free to comment.

VilppeRiskidev and others added 5 commits June 5, 2024 10:12
- `RenameProfileModal` has been separated from `Profiles.vue`
- Actions `renameProfile` and `updateProfileList` have been added to `ProfilesModule`
- Old profile renaming functionality has been removed from `Profiles` page
The previous implementation didn't take into account that the local
value is empty when user enters the Profiles screen, but an "old"
profile with a different name might be already selected if user did so
in another game's profile selection screen.

I think the proper solution would be to ensure that the active profile
is reset to null when user returns to game selection screen, but that's
a bigger change with a risk of breaking other stuff, so it's not
implemented now.
Autofocus is blocked if the URL contains fragments, which it does since
vue-router, like many SPA routers, use them to differentiate between
the pages.

Quick googling would indicate that this problem has been fixed a few
years back by WHATWG altering the HTML specification and Chromium
implementing the changes. However, in our case the issue seems to
persists. But no worries, we can achieve the same result with a few
lines of Vue code.
Also disable the rename button to indicate it does nothing if a profile
with the chosen name already exists.
@anttimaki anttimaki force-pushed the rename-profile-modal-refactor branch from c5648ab to 64c0a36 Compare June 5, 2024 08:38
Copy link
Collaborator

@anttimaki anttimaki left a comment

Choose a reason for hiding this comment

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

@VilppeRiskidev: Uno reverse card! I'll mark the PR approved but I expect you to review it after the changes I've done:

  • The PR had merge conflicts with delete-profile-modal-refactor. It almost seemed like you'd manually reproduced few of the commits from the parent branch (but missed one tiny bit). Anyways, don't do that since it makes reviewing difficult. Use git's rebase instead.
  • Addressed the few comments that I left unresolved by adding new commits. Check them out (commit messages too) to see how I solved them
  • Added a few other fixes, check them out too
  • Please test this thoroughly, I was rushing the last changes a bit since this took longer than I anticipated 😅

@VilppeRiskidev
Copy link
Collaborator Author

LGTM 👍

Base automatically changed from delete-profile-modal-refactor to develop June 11, 2024 05:36
@anttimaki anttimaki merged commit 6bb478c into develop Jun 11, 2024
7 checks passed
@anttimaki anttimaki deleted the rename-profile-modal-refactor branch June 11, 2024 05: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

2 participants