diff --git a/packages/frontend-core/src/components/grid/stores/datasources/nonPlus.ts b/packages/frontend-core/src/components/grid/stores/datasources/nonPlus.ts index 17e5e8b8d9..b21a0f3a4e 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/nonPlus.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/nonPlus.ts @@ -59,23 +59,16 @@ export const createActions = (context: StoreContext): NonPlusActions => { } } -// Small util to compare datasource definitions -const isSameDatasource = (a: any, b: any) => { - return JSON.stringify(a) === JSON.stringify(b) -} - export const initialise = (context: StoreContext) => { const { datasource, sort, filter, inlineFilters, - allFilters, nonPlus, initialFilter, initialSortColumn, initialSortOrder, - fetch, } = context // Keep a list of subscriptions so that we can clear them when the datasource // config changes @@ -97,34 +90,5 @@ export const initialise = (context: StoreContext) => { column: get(initialSortColumn), order: get(initialSortOrder) || SortOrder.ASCENDING, }) - - // Update fetch when filter changes - unsubscribers.push( - allFilters.subscribe($allFilters => { - // Ensure we're updating the correct fetch - const $fetch = get(fetch) - if (!isSameDatasource($fetch?.options?.datasource, $datasource)) { - return - } - $fetch.update({ - filter: $allFilters, - }) - }) - ) - - // Update fetch when sorting changes - unsubscribers.push( - sort.subscribe($sort => { - // Ensure we're updating the correct fetch - const $fetch = get(fetch) - if (!isSameDatasource($fetch?.options?.datasource, $datasource)) { - return - } - $fetch.update({ - sortOrder: $sort.order || SortOrder.ASCENDING, - sortColumn: $sort.column, - }) - }) - ) }) } diff --git a/packages/frontend-core/src/components/grid/stores/datasources/table.ts b/packages/frontend-core/src/components/grid/stores/datasources/table.ts index 65d68a7d5d..26da4bca9f 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/table.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/table.ts @@ -83,10 +83,8 @@ export const createActions = (context: StoreContext): TableActions => { export const initialise = (context: StoreContext) => { const { datasource, - fetch, filter, inlineFilters, - allFilters, sort, table, initialFilter, @@ -114,34 +112,5 @@ export const initialise = (context: StoreContext) => { column: get(initialSortColumn), order: get(initialSortOrder) || SortOrder.ASCENDING, }) - - // Update fetch when filter changes - unsubscribers.push( - allFilters.subscribe($allFilters => { - // Ensure we're updating the correct fetch - const $fetch = get(fetch) - if ($fetch?.options?.datasource?.tableId !== $datasource.tableId) { - return - } - $fetch.update({ - filter: $allFilters, - }) - }) - ) - - // Update fetch when sorting changes - unsubscribers.push( - sort.subscribe($sort => { - // Ensure we're updating the correct fetch - const $fetch = get(fetch) - if ($fetch?.options?.datasource?.tableId !== $datasource.tableId) { - return - } - $fetch.update({ - sortOrder: $sort.order || SortOrder.ASCENDING, - sortColumn: $sort.column, - }) - }) - ) }) } diff --git a/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts b/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts index e18b9f71c0..8c8752541d 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts @@ -97,14 +97,12 @@ export const initialise = (context: StoreContext) => { rows, filter, inlineFilters, - allFilters, subscribe, viewV2, initialFilter, initialSortColumn, initialSortOrder, config, - fetch, } = context // Keep a list of subscriptions so that we can clear them when the datasource @@ -178,17 +176,6 @@ export const initialise = (context: StoreContext) => { }, }) } - - // Also update the fetch to ensure the new sort is respected. - // Ensure we're updating the correct fetch. - const $fetch = get(fetch) - if ($fetch?.options?.datasource?.id !== $datasource.id) { - return - } - $fetch.update({ - sortOrder: $sort.order, - sortColumn: $sort.column, - }) }) ) @@ -214,38 +201,6 @@ export const initialise = (context: StoreContext) => { }) ) - // Keep fetch up to date with inline filters when in the data section - unsubscribers.push( - inlineFilters.subscribe($inlineFilters => { - if (!get(config).canSaveSchema) { - return - } - const $fetch = get(fetch) - if ($fetch?.options?.datasource?.id !== $datasource.id) { - return - } - $fetch.update({ - filter: $inlineFilters, - }) - }) - ) - - // Keep fetch up to date with all filters when not in the data section - unsubscribers.push( - allFilters.subscribe($allFilters => { - if (get(config).canSaveSchema) { - return - } - const $fetch = get(fetch) - if ($fetch?.options?.datasource?.id !== $datasource.id) { - return - } - $fetch.update({ - filter: $allFilters, - }) - }) - ) - // When hidden we show columns, we need to refresh data in order to fetch // values for those columns unsubscribers.push(