feat: add possibility to list specific repositories

ListRepositories will now fetch repos with FetchRepositories only if no repositories are already
passed to the component in its default slot.
This commit is contained in:
2023-05-08 12:44:12 +02:00
parent 1678100198
commit 1e3e15ab4e
7 changed files with 119 additions and 75 deletions

View File

@@ -19,7 +19,7 @@ const props = defineProps({
required: false,
type: Number,
},
data: {
alreadyKnownData: {
default: null,
type: Object,
},
@@ -50,14 +50,20 @@ const storeInCache = (
};
if (isDataOutdated(props.name)) {
emits('cached', storeInCache(props.callback, props.data, props.name));
emits(
'cached',
storeInCache(props.callback, props.alreadyKnownData, props.name)
);
} else {
let data = localStorage.getItem(props.name);
try {
emits('cached', of(JSON.parse(data)));
} catch (err) {
console.error(`Could not parse data found in cache: ${err}`);
emits('cached', storeInCache(props.callback, props.data, props.name));
emits(
'cached',
storeInCache(props.callback, props.alreadyKnownData, props.name)
);
}
}
</script>