Don't display toast on updating empty profile
| @@ -185,16 +185,10 @@ async function applyConnectionProfile(profile) { | |||
| 185 | 185 | ||
| 186 | /** | 186 | /** |
| 187 | * Updates the selected connection profile. | 187 | * Updates the selected connection profile. |
| 188 | * @param {ConnectionProfile} profile Connection profile | ||
| 188 | * @returns {Promise<void>} | 189 | * @returns {Promise<void>} |
| 189 | */ | 190 | */ |
| 190 | async function updateConnectionProfile() { | 191 | async function updateConnectionProfile(profile) { |
| 191 | const selectedProfile = extension_settings.connectionManager.selectedProfile; | ||
| 192 | const profile = extension_settings.connectionManager.profiles.find(p => p.id === selectedProfile); | ||
| 193 | if (!profile) { | ||
| 194 | console.log('No profile selected'); | ||
| 195 | return; | ||
| 196 | } | ||
| 197 | |||
| 198 | profile.mode = main_api === 'openai' ? 'cc' : 'tc'; | 192 | profile.mode = main_api === 'openai' ? 'cc' : 'tc'; |
| 199 | await readProfileFromCommands(profile.mode, profile, true); | 193 | await readProfileFromCommands(profile.mode, profile, true); |
| 200 | } | 194 | } |
| @@ -308,7 +302,13 @@ async function renderDetailsContent(details, detailsContent) { | |||
| 308 | 302 | ||
| 309 | const updateButton = document.getElementById('update_connection_profile'); | 303 | const updateButton = document.getElementById('update_connection_profile'); |
| 310 | updateButton.addEventListener('click', async () => { | 304 | updateButton.addEventListener('click', async () => { |
| 311 | await updateConnectionProfile(); | 305 | const selectedProfile = extension_settings.connectionManager.selectedProfile; |
| 306 | const profile = extension_settings.connectionManager.profiles.find(p => p.id === selectedProfile); | ||
| 307 | if (!profile) { | ||
| 308 | console.log('No profile selected'); | ||
| 309 | return; | ||
| 310 | } | ||
| 311 | await updateConnectionProfile(profile); | ||
| 312 | await renderDetailsContent(details, detailsContent); | 312 | await renderDetailsContent(details, detailsContent); |
| 313 | saveSettingsDebounced(); | 313 | saveSettingsDebounced(); |
| 314 | toastr.success('Connection profile updated', '', { timeOut: 1500 }); | 314 | toastr.success('Connection profile updated', '', { timeOut: 1500 }); |