fix: re-fetch instrument data after login for new machines

Auth success handler now eagerly loads instrumentSelectorData
via listPlugins + getSoundfontCatalog. The mount-time useEffect
runs before auth token is set, so it silently fails on new machines.
This commit is contained in:
2026-07-29 11:34:50 +07:00
parent 8775c960e3
commit a3e681afc0
3 changed files with 24 additions and 1 deletions
+16
View File
@@ -7593,6 +7593,22 @@ const App = () => {
window.__soundfontCatalog = cat;
}).catch(() => {});
} catch (e) { }
// Re-fetch instrument data after auth (useEffect on mount runs before token is set)
try {
window.SonicAPI.listPlugins().then(async data => {
try {
const catResp = await window.SonicAPI.getSoundfontCatalog?.() ?? await fetch('/api/v1/plugins/soundfonts/catalog').then(r => r.json());
const catalog = catResp.full_catalog || {};
data.soundfonts = (data.soundfonts || []).map(sf => {
const sfId = sf.id.replace('sf_', '');
const catEntry = catalog[sfId.toLowerCase()] || catalog[sfId];
if (catEntry && catEntry.instruments) return { ...sf, presets: catEntry.instruments };
return sf;
});
} catch (e) { console.warn('Catalog fetch error:', e); }
setInstrumentSelectorData(data);
}).catch(() => {});
} catch (e) { }
})();
}
};