From 739d0c95c3b1b2d6565a58aff06ba378b3fc5428 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sat, 7 Sep 2024 21:21:46 +0300 Subject: [PATCH] Require unique names for profiles --- public/scripts/extensions/connection-manager/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/public/scripts/extensions/connection-manager/index.js b/public/scripts/extensions/connection-manager/index.js index 3b356f2f7..77f6cf6e4 100644 --- a/public/scripts/extensions/connection-manager/index.js +++ b/public/scripts/extensions/connection-manager/index.js @@ -147,14 +147,19 @@ async function createConnectionProfile(forceName = null) { const profileForDisplay = makeFancyProfile(profile); const template = await renderExtensionTemplateAsync(MODULE_NAME, 'profile', { profile: profileForDisplay }); - const checkName = (n) => extension_settings.connectionManager.profiles.some(p => p.name === n); - const suggestedName = getUniqueName(collapseSpaces(`${profile.api ?? ''} ${profile.model ?? ''} - ${profile.preset ?? ''}`), checkName); + const isNameTaken = (n) => extension_settings.connectionManager.profiles.some(p => p.name === n); + const suggestedName = getUniqueName(collapseSpaces(`${profile.api ?? ''} ${profile.model ?? ''} - ${profile.preset ?? ''}`), isNameTaken); const name = forceName ?? await callGenericPopup(template, POPUP_TYPE.INPUT, suggestedName, { rows: 2 }); if (!name) { return null; } + if (isNameTaken(name)) { + toastr.error('A profile with the same name already exists.'); + return null; + } + profile.name = name; return profile; }