Skip to content

Commit

Permalink
get rid of unnecessary props
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarkauskas committed Mar 19, 2024
1 parent 767f510 commit 77aa38f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 29 deletions.
17 changes: 1 addition & 16 deletions src/view/app/Indexes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
import { createRoot } from 'react-dom/client';
import { TableDetails } from '@app/model';
import './indexes.css';
import Indexes from './indexes';
import { ISettings } from '@src/common/IExtensionSettings';

declare global {
interface Window {
acquireVsCodeApi(): any;
tableDetails: TableDetails;
configuration: ISettings;
}
}

const root = createRoot(document.getElementById('root'));
root.render(
<Indexes
tableDetails={window.tableDetails}
configuration={window.configuration}
/>
);
root.render(<Indexes />);
17 changes: 6 additions & 11 deletions src/view/app/Indexes/indexes.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import * as React from 'react';
import { useState, useMemo } from 'react';
import { CommandAction, IndexRow, TableDetails } from '../model';
import { CommandAction, IndexRow } from '../model';
import DataGrid from 'react-data-grid';
import type { SortColumn } from 'react-data-grid';
import * as columnName from './column.json';
import { Logger } from '../../../common/Logger';
import { ISettings } from '../../../common/IExtensionSettings';
import { getVSCodeAPI } from '@utils/vscode';

interface IConfigProps {
tableDetails: TableDetails;
configuration: ISettings;
}
import { getVSCodeAPI, getVSCodeConfiguration } from '@utils/vscode';

type Comparator = (a: IndexRow, b: IndexRow) => number;
function getComparator(sortColumn: string): Comparator {
Expand All @@ -31,16 +25,17 @@ function rowKeyGetter(row: IndexRow) {
return row.cName;
}

function Indexes({ tableDetails, configuration }: IConfigProps) {
const [rows, setRows] = useState(tableDetails?.indexes || []);
function Indexes() {
const [rows, setRows] = useState<IndexRow[]>([]);
const [dataLoaded, setDataLoaded] = useState(false);
const [sortColumns, setSortColumns] = useState<readonly SortColumn[]>([]);
const [selectedRows, setSelectedRows] = useState<ReadonlySet<string>>(
() => new Set()
);
const [windowHeight, setWindowHeight] = React.useState(window.innerHeight);
const logger = new Logger(configuration.logging.react);
const vscode = getVSCodeAPI();
const configuration = getVSCodeConfiguration();
const logger = new Logger(configuration.logging.react);

const windowRezise = () => {
setWindowHeight(window.innerHeight);
Expand Down
4 changes: 2 additions & 2 deletions src/webview/PanelViewProvider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path = require('path');
import * as vscode from 'vscode';
import { Constants } from '../common/Constants';
import { CommandAction, ICommand, TableDetails } from '../view/app/model';
import { CommandAction, ICommand } from '../view/app/model';
import { TableNode } from '../treeview/TableNode';
import { TablesListProvider } from '../treeview/TablesListProvider';
import { FavoritesProvider } from '../treeview/FavoritesProvider';
Expand Down Expand Up @@ -32,7 +32,7 @@ export class PanelViewProvider implements vscode.WebviewViewProvider {
};
this._view.webview.html = this.getWebviewContent();

this._view.onDidChangeVisibility((ev) => {
this._view.onDidChangeVisibility(() => {
if (this._view?.visible) {
if (this.tableNode) {
this.tableListProvider?.displayData(this.tableNode);
Expand Down

0 comments on commit 77aa38f

Please sign in to comment.