diff --git a/src/preload/sql.ts b/src/preload/sql.ts index 8345adb..58110ef 100644 --- a/src/preload/sql.ts +++ b/src/preload/sql.ts @@ -1,4 +1,5 @@ import { ipcRenderer } from 'electron'; +import { ResultSetHeader } from 'mysql2'; import { decodeError } from '../sql/errorSerializer'; import type { KeyColumnUsageRow, @@ -11,7 +12,6 @@ import type { } from '../sql/types'; import { bindChannel, bindEvent } from './bindChannel'; import { SQL_CHANNEL } from './sqlChannel'; -import { ResultSetHeader } from 'mysql2'; interface Sql { executeQuery(query: string): QueryResult; @@ -26,7 +26,7 @@ interface Sql { showTableStatus(): QueryResult; handlePendingEdits( PendingEdit: Array - ): Array>; + ): Promise>>; } async function doInvokeQuery(sqlChannel: SQL_CHANNEL, ...params: unknown[]) { diff --git a/src/renderer/component/TableGrid.tsx b/src/renderer/component/TableGrid.tsx index ee6837c..2fca8be 100644 --- a/src/renderer/component/TableGrid.tsx +++ b/src/renderer/component/TableGrid.tsx @@ -66,7 +66,7 @@ function TableGrid({ }), // how to render a data cell in this column - render: (value, record) => ( + render: (value: Row[keyof Row], record: Row) => ( ), }))} @@ -97,7 +97,7 @@ function CellWithPendingValue({ field, record, }: { - value: any; + value: RowDataPacket[keyof RowDataPacket]; field: FieldPacket; record: RowDataPacket; }) { @@ -147,6 +147,7 @@ type CellProps = { function EditableCell({ children, dataIndex, + // eslint-disable-next-line @typescript-eslint/no-unused-vars title, tableName, value, diff --git a/src/renderer/component/TableLayout/TableLayout.tsx b/src/renderer/component/TableLayout/TableLayout.tsx index efd3f38..a294f36 100644 --- a/src/renderer/component/TableLayout/TableLayout.tsx +++ b/src/renderer/component/TableLayout/TableLayout.tsx @@ -61,18 +61,20 @@ export function TableLayout({ return
{error.message}
; } - const resultWithActiveEdits = result?.map((row) => { - const pendingEdits = findPendingEdits(row, tableName); + const resultWithActiveEdits = result + ? result.map((row) => { + const pendingEdits = findPendingEdits(row, tableName); - return pendingEdits.reduce((acc, pendingEdit) => { - const { values } = pendingEdit; + return pendingEdits.reduce((acc, pendingEdit) => { + const { values } = pendingEdit; - return { - ...acc, - ...values, - }; - }, row); - }); + return { + ...acc, + ...values, + }; + }, row); + }) + : null; return ( diff --git a/src/sql/index.ts b/src/sql/index.ts index fa5c2fd..db2fcb8 100644 --- a/src/sql/index.ts +++ b/src/sql/index.ts @@ -9,7 +9,6 @@ import { KeyColumnUsageRow, PendingEdit, PendingEditState, - QueryResult, QueryReturnType, ShowDatabasesResult, ShowKeyRow, @@ -149,19 +148,19 @@ class ConnectionStack { async handlePendingEdits( pendingEdits: Array - ): Promise>> { + ): Promise>>> { invariant(this.#currentConnectionSlug, 'Connection slug is required'); const connection = await this.#getConnection(this.#currentConnectionSlug); - return await Promise.all( + return Promise.all( pendingEdits .filter( (edit) => edit.connectionSlug === this.#currentConnectionSlug && edit.state === PendingEditState.Pending ) - .map(async (edit) => { + .map(async (edit): Promise> => { const { tableName, primaryKeys, values } = edit; const keys = Object.keys(primaryKeys);