From afd0b677de777c7e060787c4e9f5e56ada59a0cd Mon Sep 17 00:00:00 2001 From: Khai Truong <56820749+khaitruong922@users.noreply.github.com> Date: Tue, 5 Nov 2024 01:33:01 +0700 Subject: [PATCH] Set editing profile index correctly when deleting profile (#1560) * handle editing profile index correctly when delete profile * lint * simplify index calculation * rename variables * Revert "rename variables" This reverts commit 4d81d24415703a732dee19a1e2dd525c288d190b. --- ext/js/pages/settings/profile-controller.js | 6 ++++-- ext/js/pages/settings/settings-controller.js | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ext/js/pages/settings/profile-controller.js b/ext/js/pages/settings/profile-controller.js index 11f5a9ea00..84dcb19ef5 100644 --- a/ext/js/pages/settings/profile-controller.js +++ b/ext/js/pages/settings/profile-controller.js @@ -259,8 +259,10 @@ export class ProfileController { this._updateProfileSelectOptions(); // Update profile index - if (settingsProfileIndex === profileIndex) { - this._settingsController.profileIndex = profileCurrentNew; + if (settingsProfileIndex >= profileIndex) { + this._settingsController.profileIndex = settingsProfileIndex - 1; + } else { + this._settingsController.refreshProfileIndex(); } // Modify settings diff --git a/ext/js/pages/settings/settings-controller.js b/ext/js/pages/settings/settings-controller.js index ee44f875f3..09057818f5 100644 --- a/ext/js/pages/settings/settings-controller.js +++ b/ext/js/pages/settings/settings-controller.js @@ -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;