diff --git a/src/lib/dataset/index.ts b/src/lib/dataset/index.ts index c9a817f812..1a2d980800 100644 --- a/src/lib/dataset/index.ts +++ b/src/lib/dataset/index.ts @@ -12,7 +12,11 @@ export type ColumnTypeMapping = { export type DataSetColumn = { name: string; type?: DataSetColumnType; - isUniqueValuesLoading?: boolean; // It will be updated by backendify function + /** + * indicates if there's an ongoing operation to fetch all unique values for this column from the database. + * This value is updated by the `backendify` function. + */ + isUniqueValuesLoading?: boolean; }; /** diff --git a/src/store/getters.ts b/src/store/getters.ts index 799d91e533..94da8ce31a 100644 --- a/src/store/getters.ts +++ b/src/store/getters.ts @@ -86,8 +86,7 @@ const getters: GetterTree = { * helper that is True if unique values are loading */ isUniqueValuesLoading: (state: VQBState) => (column: string) => - state.dataset.headers[state.dataset.headers.map(col => col.name).indexOf(column)] - .isUniqueValuesLoading, + state.dataset.headers.find(hdr => hdr.name === column)?.isUniqueValuesLoading, /** * Return current edited pipeline */ diff --git a/src/store/mutations.ts b/src/store/mutations.ts index 21454d87d2..741c92921d 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -291,9 +291,8 @@ class Mutations { state: VQBState, { isLoading, column }: { isLoading: boolean; column: string }, ) { - state.dataset.headers[ - state.dataset.headers.map(col => col.name).indexOf(column) - ].isUniqueValuesLoading = isLoading; + const columnName = state.dataset.headers.find(hdr => hdr.name === column); + columnName === undefined ? undefined : (columnName.isUniqueValuesLoading = isLoading); } /**