Skip to content

Commit

Permalink
chore(kmore): update builder.pagingGroupKey generation rule
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Nov 21, 2024
1 parent e7adc1e commit 29ee29b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/kmore/src/lib/hook/paging.pre.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ async function genBuilderForPaging(options: BuilderHookOptions): Promise<GenBuil
writable: true,
value: KmoreBuilderType.counter,
})

const { pagingGroupKey } = builderPager
assert(pagingGroupKey, 'pagingGroupKey should be set on builderPager')
void Object.defineProperty(builderCounter, KmorePageKey.pagingGroupKey, {
...defaultPropDescriptor,
value: builder.kmoreQueryId,
value: pagingGroupKey,
})

const total = await builderCounter
Expand Down Expand Up @@ -170,10 +173,15 @@ function cloneBuilder(
const kmoreQueryId2 = Symbol(key + '-pager')
let builderPager = builder.clone() as KmoreQueryBuilder

const pagingGroupKey = builder[KmorePageKey.pagingGroupKey]
let { pagingGroupKey } = builder
if (! pagingGroupKey) {
const key2 = builder.kmoreQueryId.toString().replace('Symbol(', '').replace(')', '')
pagingGroupKey = Symbol(key2 + '-paging-group')
}

void Object.defineProperty(builderPager, KmorePageKey.pagingGroupKey, {
...defaultPropDescriptor,
value: pagingGroupKey ?? kmoreQueryId,
value: pagingGroupKey,
})

updateBuilderProperties(
Expand Down

0 comments on commit 29ee29b

Please sign in to comment.