Browse Source

refactor(nocodb): adopt getList new format in View.ts

pull/5430/head
Wing-Kam Wong 2 years ago
parent
commit
e71230a0d4
  1. 24
      packages/nocodb/src/lib/models/View.ts

24
packages/nocodb/src/lib/models/View.ts

@ -205,8 +205,10 @@ export default class View implements ViewType {
} }
public static async list(modelId: string, ncMeta = Noco.ncMeta) { public static async list(modelId: string, ncMeta = Noco.ncMeta) {
let viewsList = await NocoCache.getList(CacheScope.VIEW, [modelId]); const cachedList = await NocoCache.getList(CacheScope.VIEW, [modelId]);
if (!viewsList.length) { let { list: viewsList } = cachedList;
const { isEmptyList } = cachedList;
if (!isEmptyList && !viewsList.length) {
viewsList = await ncMeta.metaList2(null, null, MetaTable.VIEWS, { viewsList = await ncMeta.metaList2(null, null, MetaTable.VIEWS, {
condition: { condition: {
fk_model_id: modelId, fk_model_id: modelId,
@ -1123,8 +1125,10 @@ export default class View implements ViewType {
); );
// get existing cache // get existing cache
const dataList = await NocoCache.getList(scope, [viewId]); const cachedList = await NocoCache.getList(scope, [viewId]);
if (dataList?.length) { let { list: dataList } = cachedList;
const { isEmptyList } = cachedList;
if (!isEmptyList && dataList?.length) {
for (const o of dataList) { for (const o of dataList) {
if (!ignoreColdIds?.length || !ignoreColdIds.includes(o.fk_column_id)) { if (!ignoreColdIds?.length || !ignoreColdIds.includes(o.fk_column_id)) {
// set data // set data
@ -1209,7 +1213,9 @@ export default class View implements ViewType {
} }
// get existing cache // get existing cache
const dataList = await NocoCache.getList(scope, [viewId]); const cachedList = await NocoCache.getList(scope, [viewId]);
let { list: dataList } = cachedList;
const { isEmptyList } = cachedList;
const colsEssentialForView = const colsEssentialForView =
view.type === ViewTypes.MAP view.type === ViewTypes.MAP
@ -1218,7 +1224,7 @@ export default class View implements ViewType {
const mergedIgnoreColdIds = [...ignoreColdIds, ...colsEssentialForView]; const mergedIgnoreColdIds = [...ignoreColdIds, ...colsEssentialForView];
if (dataList?.length) { if (!isEmptyList && dataList?.length) {
for (const o of dataList) { for (const o of dataList) {
if ( if (
!mergedIgnoreColdIds?.length || !mergedIgnoreColdIds?.length ||
@ -1257,8 +1263,10 @@ export default class View implements ViewType {
} }
static async shareViewList(tableId, ncMeta = Noco.ncMeta) { static async shareViewList(tableId, ncMeta = Noco.ncMeta) {
let sharedViews = await NocoCache.getList(CacheScope.VIEW, [tableId]); let cachedList = await NocoCache.getList(CacheScope.VIEW, [tableId]);
if (!sharedViews.length) { let { list: sharedViews } = cachedList;
const { isEmptyList } = cachedList;
if (!isEmptyList && !sharedViews.length) {
sharedViews = await ncMeta.metaList2(null, null, MetaTable.VIEWS, { sharedViews = await ncMeta.metaList2(null, null, MetaTable.VIEWS, {
xcCondition: { xcCondition: {
fk_model_id: { fk_model_id: {

Loading…
Cancel
Save