@@ -253,11 +253,35 @@ export default defineComponent({
253253
254254 const retrieveSettings = async () => {
255255 const s = await user .value ?.getCourseSettings (props ._id );
256+
256257 if (s ?.midiinput ) {
257- selectedInput .value = s .midiinput .toString ();
258+ const savedInput = s .midiinput .toString ();
259+ // Check if the saved input device is still available
260+ const inputExists = inputs .value .some ((input ) => input .value === savedInput );
261+ if (inputExists ) {
262+ selectedInput .value = savedInput ;
263+ } else {
264+ alertUser ({
265+ text: ` Configured MIDI input device is no longer available ` ,
266+ status: Status .error ,
267+ });
268+ console .warn (' Previously saved MIDI input device is no longer available' );
269+ }
258270 }
271+
259272 if (s ?.midioutput ) {
260- selectedOutput .value = s .midioutput .toString ();
273+ const savedOutput = s .midioutput .toString ();
274+ // Check if the saved output device is still available
275+ const outputExists = outputs .value .some ((output ) => output .value === savedOutput );
276+ if (outputExists ) {
277+ selectedOutput .value = savedOutput ;
278+ } else {
279+ alertUser ({
280+ text: ` Configured MIDI output device is no longer available ` ,
281+ status: Status .error ,
282+ });
283+ console .warn (' Previously saved MIDI output device is no longer available' );
284+ }
261285 }
262286 };
263287
@@ -306,10 +330,16 @@ export default defineComponent({
306330 outputs .value = [{ title: ' No outputs available' , value: ' ' }];
307331 }
308332
309- selectedInput .value = inputs .value .length > 0 ? inputs .value [0 ].value : ' ' ;
310- selectedOutput .value = outputs .value .length > 0 ? outputs .value [0 ].value : ' ' ;
333+ await retrieveSettings ();
334+
335+ // Only set defaults if no saved settings were loaded
336+ if (! selectedInput .value && inputs .value .length > 0 ) {
337+ selectedInput .value = inputs .value [0 ].value ;
338+ }
311339
312- retrieveSettings ();
340+ if (! selectedOutput .value && outputs .value .length > 0 ) {
341+ selectedOutput .value = outputs .value [0 ].value ;
342+ }
313343 }
314344 });
315345
0 commit comments