Skip to content

Commit

Permalink
code review fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Vyacheslav Tumanov <[email protected]>
  • Loading branch information
ThetaDR committed May 20, 2024
1 parent 8f31b60 commit a700162
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
29 changes: 18 additions & 11 deletions plugins/view-resources/src/components/list/ListCategories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -349,21 +349,28 @@
const listCategory: SvelteComponentTyped[] = []
const listListCategory: ListCategory[] = []
function getGroupByKey (
docKeys: Partial<DocumentQuery<Doc<Space>>>,
category: CategoryType,
resultQuery: DocumentQuery<Doc<Space>>
): Partial<DocumentQuery<Doc>> {
return {
...docKeys,
[groupByKey]:
typeof category === 'object'
? category.name !== undefined
? { $in: category.values.flatMap((x) => x._id) }
: resultQuery[groupByKey]?.$in?.length !== 0
? undefined
: []
: category
}
}
</script>

{#each categories as category, i (typeof category === 'object' ? category.name : category)}
{@const items = groupByKey === noCategory ? docs : getGroupByValues(groupByDocs, category)}
{@const categoryDocKeys = {
...docKeys,
[groupByKey]:
typeof category === 'object'
? category.name !== undefined
? { $in: category.values.flatMap((x) => x._id) }
: resultQuery[groupByKey]?.$in?.length !== 0
? undefined
: []
: category
}}
{@const categoryDocKeys = getGroupByKey(docKeys, category, resultQuery)}
{#if items.length !== 0}
<ListCategory
bind:this={listListCategory[i]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,12 @@
$: if (lastLevel) {
void limiter.add(async () => {
// console.log('category Query', _class, { ...resultQuery, ...docKeys })
loading = docsQuery.query(
_class,
{ ...resultQuery, ...docKeys },
(res) => {
items = res
loading = false
console.log({ docKeys }, res)
const focusDoc = items.find((it) => it._id === $focusStore.focus?._id)
if (focusDoc) {
handleRowFocused(focusDoc)
Expand Down

0 comments on commit a700162

Please sign in to comment.