Don't display toast on updating empty profile

c4aa79a8e1c371c0426f6d77d86e21770cbac2b8

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +9 -9Showing whitespace changes
public/scripts/extensions/connection-manager/index.js+9 -9
@@ -185,16 +185,10 @@ async function applyConnectionProfile(profile) {
185185
186186/**
187187 * Updates the selected connection profile.
188+ * @param {ConnectionProfile} profile Connection profile
188189 * @returns {Promise<void>}
189190 */
190191async 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-
198192 profile.mode = main_api === 'openai' ? 'cc' : 'tc';
199193 await readProfileFromCommands(profile.mode, profile, true);
200194}
@@ -308,7 +302,13 @@ async function renderDetailsContent(details, detailsContent) {
308302
309303 const updateButton = document.getElementById('update_connection_profile');
310304 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);
312312 await renderDetailsContent(details, detailsContent);
313313 saveSettingsDebounced();
314314 toastr.success('Connection profile updated', '', { timeOut: 1500 });