11import api from "@/api/api" ;
22import { useResourceStore } from "@/store/resource.store" ;
33import useSpin from "@/spin/spin.composable" ;
4+ import type { Metadata } from "@/store/resource.types" ;
45
56/** Tracks fully loaded resources, so subsequent load calls can be skipped. */
67const isFresh : Record < string , true > = { } ;
@@ -10,20 +11,22 @@ export default function useMetadata(resourceId: string) {
1011 const { spin } = useSpin ( ) ;
1112
1213 /** Load data about a metadata and store it. */
13- async function loadMetadata ( ) : Promise < void > {
14+ async function loadMetadata ( ) : Promise < Metadata | undefined > {
1415 // Make sure the resource has an entry in the store.
15- await resourceStore . loadResource ( resourceId ) ;
16+ const resource = ( await resourceStore . loadResource ( resourceId ) ) as Metadata ;
1617
1718 // Skip if already loaded.
18- if ( isFresh [ resourceId ] ) return ;
19-
20- // Load remaining essential info, unless removed.
21- if ( resourceId in resourceStore . metadatas ) {
22- await loadYaml ( ) ;
19+ if ( ! isFresh [ resourceId ] ) {
20+ // Load remaining essential info, unless removed.
21+ if ( resourceId in resourceStore . metadatas ) {
22+ await loadYaml ( ) ;
23+ }
2324 }
2425
2526 // Remember to skip loading next time.
2627 isFresh [ resourceId ] = true ;
28+
29+ return resource ;
2730 }
2831
2932 /** Load and store the metadata yaml string. */
0 commit comments