Browse Source

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

pull/5430/head
Wing-Kam Wong 2 years ago
parent
commit
83b724f2cd
  1. 17
      packages/nocodb/src/lib/models/GridViewColumn.ts

17
packages/nocodb/src/lib/models/GridViewColumn.ts

@ -24,8 +24,12 @@ export default class GridViewColumn implements GridColumnType {
viewId: string, viewId: string,
ncMeta = Noco.ncMeta ncMeta = Noco.ncMeta
): Promise<GridViewColumn[]> { ): Promise<GridViewColumn[]> {
let views = await NocoCache.getList(CacheScope.GRID_VIEW_COLUMN, [viewId]); const cachedList = await NocoCache.getList(CacheScope.GRID_VIEW_COLUMN, [
if (!views.length) { viewId,
]);
let { list: views } = cachedList;
const { isEmptyList } = cachedList;
if (!isEmptyList && !views.length) {
views = await ncMeta.metaList2(null, null, MetaTable.GRID_VIEW_COLUMNS, { views = await ncMeta.metaList2(null, null, MetaTable.GRID_VIEW_COLUMNS, {
condition: { condition: {
fk_view_id: viewId, fk_view_id: viewId,
@ -99,13 +103,10 @@ export default class GridViewColumn implements GridColumnType {
await NocoCache.set(`${CacheScope.GRID_VIEW_COLUMN}:${fk_column_id}`, id); await NocoCache.set(`${CacheScope.GRID_VIEW_COLUMN}:${fk_column_id}`, id);
// if cache is not present skip pushing it into the list to avoid unexpected behaviour // if cache is not present skip pushing it into the list to avoid unexpected behaviour
if ( const { list } = await NocoCache.getList(CacheScope.GRID_VIEW_COLUMN, [
(
await NocoCache.getList(CacheScope.GRID_VIEW_COLUMN, [
column.fk_view_id, column.fk_view_id,
]) ]);
)?.length if (list.length)
)
await NocoCache.appendToList( await NocoCache.appendToList(
CacheScope.GRID_VIEW_COLUMN, CacheScope.GRID_VIEW_COLUMN,
[column.fk_view_id], [column.fk_view_id],

Loading…
Cancel
Save