Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: resolve conflict and remove redundant changes

gitstartc2e58be65112
diff --git a/studio/components/grid/components/footer/pagination/Pagination.tsx b/studio/components/grid/components/footer/pagination/Pagination.tsx
index c0a68b2b5ad..534bfc29088 100644
--- a/studio/components/grid/components/footer/pagination/Pagination.tsx
+++ b/studio/components/grid/components/footer/pagination/Pagination.tsx
@@ -6,7 +6,6 @@ import { useTableRowsCountQuery } from 'data/table-rows/table-rows-count-query'
import { DropdownControl } from '../../common'
import { useDispatch, useTrackedState } from '../../../store'
import { confirmAlert } from 'components/to-be-cleaned/ModalsDeprecated/ConfirmModal'
-import { REFRESH_PAGE_AFTER_DELETED_ROWS } from 'components/grid/constants'
import { formatFilterURLParams } from 'components/grid/SupabaseGrid.utils'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
@@ -47,20 +46,29 @@ const Pagination = ({ isLoading: isLoadingRows = false }: PaginationProps) => {
table,
filters,
},
- { keepPreviousData: true }
+ {
+ keepPreviousData: true,
+ onSuccess(data) {
+ dispatch({
+ type: 'SET_ROWS_COUNT',
+ payload: data.count,
+ })
+ },
+ }
)
const maxPages = Math.ceil((data?.count ?? 0) / state.rowsPerPage)
const totalPages = (data?.count ?? 0) > 0 ? maxPages : 1
- // [Joshen] Oddly without this, state.selectedRows will be stale
- useEffect(() => {}, [state.selectedRows])
-
useEffect(() => {
- if (state.refreshPageFlag === REFRESH_PAGE_AFTER_DELETED_ROWS) {
- setPage(state.page)
+ if (page && page > totalPages) {
+ setPage(totalPages)
+ dispatch({ type: 'SET_PAGE', payload: totalPages })
}
- }, [state.page, state.refreshPageFlag])
+ }, [page, totalPages])
+
+ // [Joshen] Oddly without this, state.selectedRows will be stale
+ useEffect(() => {}, [state.selectedRows])
// [Joshen] Note: I've made pagination buttons disabled while rows are being fetched for now
// at least until we can send an abort signal to cancel requests if users are mashing the
diff --git a/studio/components/grid/constants.ts b/studio/components/grid/constants.ts
index 55e6ffcd32e..1f4b8caf92e 100644
--- a/studio/components/grid/constants.ts
+++ b/studio/components/grid/constants.ts
@@ -7,7 +7,6 @@ export const COLUMN_MIN_WIDTH = 100
export const STORAGE_KEY_PREFIX = 'supabase_grid'
export const REFRESH_PAGE_IMMEDIATELY = -1
-export const REFRESH_PAGE_AFTER_DELETED_ROWS = -3
export const TOTAL_ROWS_INITIAL = -1
export const TOTAL_ROWS_RESET = -2
diff --git a/studio/components/grid/store/reducers/row.ts b/studio/components/grid/store/reducers/row.ts
index e5f06700bc4..504691240ad 100644
--- a/studio/components/grid/store/reducers/row.ts
+++ b/studio/components/grid/store/reducers/row.ts
@@ -141,18 +141,6 @@ const RowReducer = (state: RowInitialState, action: ROW_ACTIONTYPE) => {
}),
}
}
- case 'REMOVE_ROWS': {
- const totalRows = state.totalRows - action.payload.rowIdxs.length
- const maxPages = Math.ceil(totalRows / state.rowsPerPage)
-
- return {
- ...state,
- rows: state.rows.filter((x) => !action.payload.rowIdxs.includes(x.idx)),
- totalRows: totalRows,
- refreshPageFlag: state.totalRows > state.rowsPerPage ? REFRESH_PAGE_AFTER_DELETED_ROWS : 0,
- page: Math.min(state.page, maxPages),
- }
- }
case 'REMOVE_ALL_ROWS': {
return {
...state,