Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

fix(scanner): guard AR overlay against locations with no children (#1741)

John Costaa962eb3b464b
diff --git a/frontend/components/Scanner/AROverlayCard.vue b/frontend/components/Scanner/AROverlayCard.vue
index 7fd71331..4b74cf1e 100644
--- a/frontend/components/Scanner/AROverlayCard.vue
+++ b/frontend/components/Scanner/AROverlayCard.vue
@@ -52,7 +52,10 @@
<div v-else-if="entity.location" class="flex flex-col gap-1">
<span class="truncate text-sm font-semibold text-foreground">{{ entity.location.name }}</span>
<div class="flex flex-wrap items-center gap-1.5">
- <span v-if="entity.location.children.length > 0" class="text-xs text-muted-foreground">
+ <span
+ v-if="entity.location.children && entity.location.children.length > 0"
+ class="text-xs text-muted-foreground"
+ >
{{ entity.location.children.length }}
{{ t("scanner_ar.children", { count: entity.location.children.length }) }}
</span>
diff --git a/frontend/composables/use-barcode-detector.ts b/frontend/composables/use-barcode-detector.ts
index 4fbcc3b9..97a24b1a 100644
--- a/frontend/composables/use-barcode-detector.ts
+++ b/frontend/composables/use-barcode-detector.ts
@@ -416,7 +416,7 @@ export function useBarcodeDetector(videoRef: Ref<HTMLVideoElement | undefined>)
return null;
}
- const [locRes, itemsRes] = await Promise.all([api.locations.get(id), api.items.getAll({ locations: [id] })]);
+ const [locRes, itemsRes] = await Promise.all([api.locations.get(id), api.items.getAll({ parentIds: [id] })]);
if (locRes.data) {
const result: EntityData = { location: locRes.data, childItems: itemsRes.data?.items ?? [] };
entityCache.set(cacheKey, { data: result, fetchedAt: Date.now() });