diff --git a/plugins/view-resources/src/components/filter/FilterSection.svelte b/plugins/view-resources/src/components/filter/FilterSection.svelte index b1c1b41305..1d326930fb 100644 --- a/plugins/view-resources/src/components/filter/FilterSection.svelte +++ b/plugins/view-resources/src/components/filter/FilterSection.svelte @@ -31,11 +31,22 @@ let current = 0 const client = getClient() const hierarchy = client.getHierarchy() - const targetClass = (hierarchy.getAttribute(_class, filter.key.key).type as RefTo).to + + function getTargetClass (): Ref> | undefined { + try { + return (hierarchy.getAttribute(_class, filter.key.key).type as RefTo).to + } catch (err: any) { + console.error(err) + } + } + const targetClass = getTargetClass() $: isState = targetClass === task.class.State ?? false const dispatch = createEventDispatcher() async function getCountStates (ids: Ref[]): Promise { + if (targetClass === undefined) { + return 0 + } const selectStates = await client.findAll(targetClass, { _id: { $in: Array.from(ids) } }, {}) const unique = new Set(selectStates.map((s) => (s as State).title)) return unique.size