From c4aa79a8e1c371c0426f6d77d86e21770cbac2b8 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sat, 7 Sep 2024 00:30:47 +0300 Subject: [PATCH] Don't display toast on updating empty profile --- .../extensions/connection-manager/index.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/public/scripts/extensions/connection-manager/index.js b/public/scripts/extensions/connection-manager/index.js index f3b3898d2..91c0f459d 100644 --- a/public/scripts/extensions/connection-manager/index.js +++ b/public/scripts/extensions/connection-manager/index.js @@ -185,16 +185,10 @@ async function applyConnectionProfile(profile) { /** * Updates the selected connection profile. + * @param {ConnectionProfile} profile Connection profile * @returns {Promise} */ -async function updateConnectionProfile() { - const selectedProfile = extension_settings.connectionManager.selectedProfile; - const profile = extension_settings.connectionManager.profiles.find(p => p.id === selectedProfile); - if (!profile) { - console.log('No profile selected'); - return; - } - +async function updateConnectionProfile(profile) { profile.mode = main_api === 'openai' ? 'cc' : 'tc'; await readProfileFromCommands(profile.mode, profile, true); } @@ -308,7 +302,13 @@ async function renderDetailsContent(details, detailsContent) { const updateButton = document.getElementById('update_connection_profile'); updateButton.addEventListener('click', async () => { - await updateConnectionProfile(); + const selectedProfile = extension_settings.connectionManager.selectedProfile; + const profile = extension_settings.connectionManager.profiles.find(p => p.id === selectedProfile); + if (!profile) { + console.log('No profile selected'); + return; + } + await updateConnectionProfile(profile); await renderDetailsContent(details, detailsContent); saveSettingsDebounced(); toastr.success('Connection profile updated', '', { timeOut: 1500 });