Fix Reactivity issue with library imports when changing version

This commit is contained in:
2025-07-13 07:35:22 +00:00
committed by Jim Hamill
parent 6d79bcaa92
commit 4ae35eb852
7 changed files with 35 additions and 35 deletions
@@ -9,7 +9,7 @@ export type ImportedLib = {
export type XOCashLibs = {
'@xocash/stack': ImportedLib;
'@xocash/primitives': ImportedLib;
}
};
const xocashLibs = reactive<XOCashLibs>({
'@xocash/stack': {
@@ -64,8 +64,14 @@ export const useXOCashLibs = (): XOCashLibs => {
// Fetch the versions and set the selected version when the component is mounted.
onMounted(async () => {
xocashLibs['@xocash/stack'].versions = await getVersions();
xocashLibs['@xocash/stack'].selectedVersion =
xocashLibs['@xocash/stack'].versions[xocashLibs['@xocash/stack'].versions.length - 1];
// Only update the selected version if it is not already set.
if (!xocashLibs['@xocash/stack'].selectedVersion) {
xocashLibs['@xocash/stack'].selectedVersion =
xocashLibs['@xocash/stack'].versions[
xocashLibs['@xocash/stack'].versions.length - 1
];
}
});
return xocashLibs;