getConnectionType improved. see #604

This commit is contained in:
mic 2026-01-04 17:43:39 +01:00
parent 303bd86bac
commit d0fac711fb

View file

@ -627,25 +627,18 @@ export function isAPIKeyValue(id){
return id.endsWith('_api_key'); return id.endsWith('_api_key');
} }
export function getConnectionType(prefsOrType, prompt, prefixOrSpecific = null) { export function getConnectionType(prefs, prompt, prefix = null) {
let defaultType = ''; let defaultType = '';
let specificType = ''; let specificType = '';
if (typeof prefsOrType === 'object' && prefsOrType !== null) { if (prefs !== null) {
// New signature: (prefs, prompt, prefix) defaultType = prefs.connection_type;
defaultType = prefsOrType.connection_type; if (typeof prefix === 'string' && prefix) {
if (typeof prefixOrSpecific === 'string' && prefixOrSpecific) { const useSpecific = getDynamicSettingValue(prefs, prefix, 'use_specific_integration');
const prefix = prefixOrSpecific;
const useSpecific = getDynamicSettingValue(prefsOrType, prefix, 'use_specific_integration');
if (useSpecific) { if (useSpecific) {
specificType = getDynamicSettingValue(prefsOrType, prefix, 'connection_type'); specificType = getDynamicSettingValue(prefs, prefix, 'connection_type');
} }
} }
} else {
// Old signature / Direct usage: (connection_type_string, prompt, [specific_type_string])
if (typeof prefixOrSpecific === 'string') {
specificType = prefixOrSpecific;
}
} }
if (specificType && specificType !== '') return specificType; if (specificType && specificType !== '') return specificType;