From 649e7cc15ee6bde7208f4f0665731b0e6a7737af Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 10 Apr 2023 17:24:42 +0800 Subject: [PATCH] refactor(nocodb): adopt getList new format in HookFilter.ts --- packages/nocodb/src/lib/models/HookFilter.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/nocodb/src/lib/models/HookFilter.ts b/packages/nocodb/src/lib/models/HookFilter.ts index b9b66fb8f3..03e8e6656d 100644 --- a/packages/nocodb/src/lib/models/HookFilter.ts +++ b/packages/nocodb/src/lib/models/HookFilter.ts @@ -205,10 +205,12 @@ export default class Filter { public async getChildren(ncMeta = Noco.ncMeta): Promise { if (this.children) return this.children; if (!this.is_group) return null; - let childFilters = await NocoCache.getList(CacheScope.FILTER_EXP, [ + const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [ this.id, ]); - if (!childFilters.length) { + let { list: childFilters } = cachedList; + const { isEmptyList } = cachedList; + if (!isEmptyList && !childFilters.length) { childFilters = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, { condition: { fk_parent_id: this.id, @@ -243,8 +245,10 @@ export default class Filter { }, ncMeta = Noco.ncMeta ): Promise { - let filters = await NocoCache.getList(CacheScope.FILTER_EXP, [viewId]); - if (!filters.length) { + const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [viewId]); + let { list: filters } = cachedList; + const { isEmptyList } = cachedList; + if (!isEmptyList && !filters.length) { filters = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, { condition: { fk_view_id: viewId }, }); @@ -327,8 +331,10 @@ export default class Filter { { viewId }: { viewId: any }, ncMeta = Noco.ncMeta ) { - let filterObjs = await NocoCache.getList(CacheScope.FILTER_EXP, [viewId]); - if (!filterObjs.length) { + const cachedList = await NocoCache.getList(CacheScope.FILTER_EXP, [viewId]); + let { list: filterObjs } = cachedList; + const { isEmptyList } = cachedList; + if (!isEmptyList && !filterObjs.length) { filterObjs = await ncMeta.metaList2(null, null, MetaTable.FILTER_EXP, { condition: { fk_view_id: viewId }, });