(preferredId = '')
| 3816 | }; |
| 3817 | |
| 3818 | const renderSourceOptions = (preferredId = '') => { |
| 3819 | if (!sourceIdEl) return; |
| 3820 | let options = Array.isArray(state.sourceOptions) ? state.sourceOptions.slice() : []; |
| 3821 | if (!options.length) { |
| 3822 | options = [{ id: 'local', label: 'local - Local' }]; |
| 3823 | } |
| 3824 | if (!options.some((s) => String(s.id || '') === 'local')) { |
| 3825 | options.unshift({ id: 'local', label: 'local - Local' }); |
| 3826 | } |
| 3827 | |
| 3828 | sourceIdEl.innerHTML = ''; |
| 3829 | options.forEach((src) => { |
| 3830 | const id = String(src?.id || '').trim(); |
| 3831 | if (!id) return; |
| 3832 | const option = document.createElement('option'); |
| 3833 | option.value = id; |
| 3834 | option.textContent = String(src?.label || id); |
| 3835 | sourceIdEl.appendChild(option); |
| 3836 | }); |
| 3837 | |
| 3838 | const chosen = String(preferredId || sourceIdEl.value || 'local').trim() || 'local'; |
| 3839 | const hasChosen = options.some((s) => String(s.id || '') === chosen); |
| 3840 | sourceIdEl.value = hasChosen ? chosen : 'local'; |
| 3841 | }; |
| 3842 | |
| 3843 | const loadSourceOptions = async () => { |
| 3844 | try { |
no outgoing calls
no test coverage detected