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

Set editing profile index correctly when deleting profile #1560

Merged
merged 5 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ext/js/pages/settings/profile-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ export class ProfileController {
// Update profile index
if (settingsProfileIndex === profileIndex) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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,
            });
        }
        

Copy link
Collaborator

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?

Copy link
Author

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._settingsController.profileIndex = profileCurrentNew;
} else if (settingsProfileIndex > profileIndex) {
this._settingsController.profileIndex = settingsProfileIndex - 1;
} else {
this._settingsController.refreshProfileIndex();
}

// Modify settings
Expand Down
5 changes: 5 additions & 0 deletions ext/js/pages/settings/settings-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ export class SettingsController extends EventDispatcher {
this._setProfileIndex(value, true);
}

/** */
refreshProfileIndex() {
this._setProfileIndex(this._profileIndex, true);
}

/** @type {HtmlTemplateCollection} */
get templates() {
return this._templates;
Expand Down
Loading