Skip to content

Commit d8f5f5b

Browse files
committed
profile switching streamlined
1 parent 8bfeb14 commit d8f5f5b

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

popup-page-scripts/popup-page-profiles.js

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,37 +52,29 @@ async function loadProfiles() {
5252
*/
5353
async function switchProfile(profileName) {
5454
try {
55-
const response = await chrome.runtime.sendMessage({
55+
// Request the profile switch.
56+
await chrome.runtime.sendMessage({
5657
type: 'switchProfile',
5758
profileName: profileName
5859
});
5960

60-
let newConfig = null;
61-
62-
// If the primary response is missing config, attempt to retrieve via getConfig
63-
if (!response || !response.config) {
64-
logToConsole(`Warning: Received null config for profile "${profileName}". Attempting to retrieve default config...`);
65-
const configResponse = await chrome.runtime.sendMessage({ type: 'getConfig' });
66-
if (configResponse && configResponse.config) {
67-
newConfig = configResponse.config;
68-
} else {
69-
logToConsole('Error: Unable to retrieve default profile configuration during switchProfile.');
70-
return;
71-
}
61+
// Now retrieve the configuration for the current profile.
62+
const configResponse = await chrome.runtime.sendMessage({ type: 'getConfig' });
63+
if (configResponse && configResponse.config) {
64+
currentProfile = configResponse.config;
65+
updateInterface();
66+
logToConsole(`Switched to profile: ${profileName}`);
67+
updateSaveStatus();
7268
} else {
73-
newConfig = response.config;
69+
logToConsole(`Error: Unable to retrieve configuration after switching to profile "${profileName}".`);
7470
}
75-
76-
currentProfile = newConfig;
77-
updateInterface();
78-
logToConsole(`Switched to profile: ${profileName}`);
79-
updateSaveStatus();
8071
} catch (error) {
8172
logToConsole(`Error switching profile: ${error.message}`);
8273
}
8374
}
8475

8576

77+
8678
// -------------------------
8779
// 3. Add New Empty Profile
8880
// -------------------------

0 commit comments

Comments
 (0)