-
Notifications
You must be signed in to change notification settings - Fork 100
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
Set editing profile index correctly when deleting profile #1560
Conversation
Sorry didn't read it carefully. Have a question or two in a bit
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.
Sorry have some q's
@@ -261,6 +261,10 @@ export class ProfileController { | |||
// Update profile index | |||
if (settingsProfileIndex === profileIndex) { |
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.
if (settingsProfileIndex === profileIndex) { | |
if (settingsProfileIndex >= profileIndex) { |
Isn't this math accounted for above? Line 231
if (profileCurrentNew >= profileIndex) {
profileCurrentNew = Math.min(profileCurrentNew - 1, this._profiles.length - 1);
modifications.push({
action: 'set',
path: 'profileCurrent',
value: profileCurrentNew,
});
}
@@ -261,6 +261,10 @@ export class ProfileController { | |||
// Update profile index | |||
if (settingsProfileIndex === profileIndex) { |
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.
Also what's the difference between settingsProfileIndex
and profileIndex
?
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.
settingsProfileIndex
is editing profile index, profileIndex
is the index to be deleted. Maybe should rename this?
This reverts commit 4d81d24.
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.
yeah maybe renaming variables in this file as a separate PR would be good
Fixes #1556
Let's call editing profile index
x
and deleted profile indexy
Currently we does not handle:
x < y
: The default profile and editing profile will be reset to the first profile, however when reload the page, it still has the value before reset. Additionally, the radio button does not represent the default profile correctly. Calling_setProfileIndex
with the samex
value will resolve this.x > y
: The editing profile index is not shifted up, therefore it moves into below profile. When the editing profile is the last index, it will cause index error, and we cannot add more profiles after that. The issue happens because when we add a profile, the editing profile index is set to last index.List indexes are also updated correctly after deletion.