Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeniau committed Apr 18, 2024
1 parent 61f59be commit 5fa3b5e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/preload/sql.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ipcRenderer } from 'electron';
import { ResultSetHeader } from 'mysql2';
import { decodeError } from '../sql/errorSerializer';
import type {
KeyColumnUsageRow,
Expand All @@ -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<T extends QueryReturnType>(query: string): QueryResult<T>;
Expand All @@ -26,7 +26,7 @@ interface Sql {
showTableStatus(): QueryResult<ShowTableStatus[]>;
handlePendingEdits(
PendingEdit: Array<PendingEdit>
): Array<QueryResult<ResultSetHeader>>;
): Promise<Array<QueryResult<ResultSetHeader>>>;
}

async function doInvokeQuery(sqlChannel: SQL_CHANNEL, ...params: unknown[]) {
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/component/TableGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function TableGrid<Row extends RowDataPacket>({
}),

// how to render a data cell in this column
render: (value, record) => (
render: (value: Row[keyof Row], record: Row) => (
<CellWithPendingValue field={field} value={value} record={record} />
),
}))}
Expand Down Expand Up @@ -97,7 +97,7 @@ function CellWithPendingValue({
field,
record,
}: {
value: any;
value: RowDataPacket[keyof RowDataPacket];
field: FieldPacket;
record: RowDataPacket;
}) {
Expand Down Expand Up @@ -147,6 +147,7 @@ type CellProps = {
function EditableCell({
children,
dataIndex,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
title,
tableName,
value,
Expand Down
22 changes: 12 additions & 10 deletions src/renderer/component/TableLayout/TableLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,20 @@ export function TableLayout({
return <div>{error.message}</div>;
}

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 (
<Flex vertical gap="small" style={{ height: '100%' }}>
Expand Down
7 changes: 3 additions & 4 deletions src/sql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
KeyColumnUsageRow,
PendingEdit,
PendingEditState,
QueryResult,
QueryReturnType,
ShowDatabasesResult,
ShowKeyRow,
Expand Down Expand Up @@ -149,19 +148,19 @@ class ConnectionStack {

async handlePendingEdits(
pendingEdits: Array<PendingEdit>
): Promise<Array<QueryResult<ResultSetHeader>>> {
): Promise<Array<Awaited<QueryResultOrError<ResultSetHeader>>>> {
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<QueryResultOrError<ResultSetHeader>> => {
const { tableName, primaryKeys, values } = edit;

const keys = Object.keys(primaryKeys);
Expand Down

0 comments on commit 5fa3b5e

Please sign in to comment.