Skip to content

Commit 7a19b94

Browse files
authored
fix linting errors, fix electron vite popping up index.html, docs typescript errors, etc. (#2265)
1 parent 462a1b6 commit 7a19b94

8 files changed

Lines changed: 51 additions & 29 deletions

File tree

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,11 @@
5454
},
5555
"files.associations": {
5656
"*.css": "tailwindcss"
57+
},
58+
"go.lintTool": "staticcheck",
59+
"gopls": {
60+
"analyses": {
61+
"QF1003": false
62+
}
5763
}
5864
}

docs/docs/config.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ id: "config"
44
title: "Configuration"
55
---
66

7-
import { Kbd } from "@site/src/components/kbd.tsx";
8-
import { PlatformProvider, PlatformSelectorButton } from "@site/src/components/platformcontext.tsx";
7+
import { Kbd } from "@site/src/components/kbd";
8+
import { PlatformProvider, PlatformSelectorButton } from "@site/src/components/platformcontext";
99

1010
<PlatformProvider>
1111

docs/src/components/platformcontext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const PlatformProviderInternal = ({ children }: { children: ReactNode }) => {
4646
);
4747
};
4848

49-
export const PlatformProvider: React.FC = ({ children }: { children: ReactNode }) => {
49+
export const PlatformProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
5050
return (
5151
<BrowserOnly fallback={<div />}>
5252
{() => <PlatformProviderInternal>{children}</PlatformProviderInternal>}

electron.vite.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ export default defineConfig({
2727
"@": "frontend",
2828
},
2929
},
30+
server: {
31+
open: false,
32+
},
3033
define: {
3134
"process.env.WS_NO_BUFFER_UTIL": "true",
3235
"process.env.WS_NO_UTF_8_VALIDATE": "true",
@@ -47,6 +50,9 @@ export default defineConfig({
4750
},
4851
outDir: "dist/preload",
4952
},
53+
server: {
54+
open: false,
55+
},
5056
plugins: [tsconfigPaths(), flow()],
5157
},
5258
renderer: {

emain/emain-tabview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class WaveTabView extends WebContentsView {
7474
});
7575
wcIdToWaveTabMap.set(this.webContents.id, this);
7676
if (isDevVite) {
77-
this.webContents.loadURL(`${process.env.ELECTRON_RENDERER_URL}/index.html}`);
77+
this.webContents.loadURL(`${process.env.ELECTRON_RENDERER_URL}/index.html`);
7878
} else {
7979
this.webContents.loadFile(path.join(getElectronAppBasePath(), "frontend", "index.html"));
8080
}

emain/emain-util.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ export function handleCtrlShiftState(sender: Electron.WebContents, waveEvent: Wa
5656
}
5757

5858
export function shNavHandler(event: Electron.Event<Electron.WebContentsWillNavigateEventParams>, url: string) {
59-
if (url.startsWith("http://127.0.0.1:5173/index.html") || url.startsWith("http://localhost:5173/index.html")) {
59+
const isDev = !electron.app.isPackaged;
60+
if (isDev && (url.startsWith("http://127.0.0.1:5173/index.html") || url.startsWith("http://localhost:5173/index.html") ||
61+
url.startsWith("http://127.0.0.1:5174/index.html") || url.startsWith("http://localhost:5174/index.html"))) {
6062
// this is a dev-mode hot-reload, ignore it
6163
console.log("allowing hot-reload of index.html");
6264
return;

frontend/app/view/preview/directorypreview.tsx

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,15 @@ function DirectoryTable({
386386
useLayoutEffect(() => {
387387
const rows = table.getRowModel()?.flatRows;
388388
let foundParentDir = false;
389-
389+
390390
for (const row of rows) {
391391
if (row.getValue("name") == "..") {
392392
row.pin("top");
393393
foundParentDir = true;
394394
break;
395395
}
396396
}
397-
397+
398398
// If we didn't find the ".." row, reset the pinning to avoid stale references
399399
if (!foundParentDir) {
400400
table.resetRowPinning();
@@ -520,34 +520,39 @@ function TableBody({
520520
}: TableBodyProps) {
521521
const dummyLineRef = useRef<HTMLDivElement>();
522522
const warningBoxRef = useRef<HTMLDivElement>();
523-
const rowRefs = useRef<HTMLDivElement[]>([]);
524523
const conn = useAtomValue(model.connection);
525524
const setErrorMsg = useSetAtom(model.errorMsgAtom);
526525

527526
useEffect(() => {
528-
if (focusIndex !== null && rowRefs.current[focusIndex] && bodyRef.current && osRef) {
529-
const viewport = osRef.osInstance().elements().viewport;
530-
const viewportHeight = viewport.offsetHeight;
531-
const rowElement = rowRefs.current[focusIndex];
532-
const rowRect = rowElement.getBoundingClientRect();
533-
const parentRect = viewport.getBoundingClientRect();
534-
const viewportScrollTop = viewport.scrollTop;
535-
const rowTopRelativeToViewport = rowRect.top - parentRect.top + viewport.scrollTop;
536-
const rowBottomRelativeToViewport = rowRect.bottom - parentRect.top + viewport.scrollTop;
537-
if (rowTopRelativeToViewport - 30 < viewportScrollTop) {
538-
// Row is above the visible area
539-
let topVal = rowTopRelativeToViewport - 30;
540-
if (topVal < 0) {
541-
topVal = 0;
542-
}
543-
viewport.scrollTo({ top: topVal });
544-
} else if (rowBottomRelativeToViewport + 5 > viewportScrollTop + viewportHeight) {
545-
// Row is below the visible area
546-
const topVal = rowBottomRelativeToViewport - viewportHeight + 5;
547-
viewport.scrollTo({ top: topVal });
527+
if (focusIndex === null || !bodyRef.current || !osRef) {
528+
return;
529+
}
530+
531+
const rowElement = bodyRef.current.querySelector(`[data-rowindex="${focusIndex}"]`) as HTMLDivElement;
532+
if (!rowElement) {
533+
return;
534+
}
535+
536+
const viewport = osRef.osInstance().elements().viewport;
537+
const viewportHeight = viewport.offsetHeight;
538+
const rowRect = rowElement.getBoundingClientRect();
539+
const parentRect = viewport.getBoundingClientRect();
540+
const viewportScrollTop = viewport.scrollTop;
541+
const rowTopRelativeToViewport = rowRect.top - parentRect.top + viewport.scrollTop;
542+
const rowBottomRelativeToViewport = rowRect.bottom - parentRect.top + viewport.scrollTop;
543+
544+
if (rowTopRelativeToViewport - 30 < viewportScrollTop) {
545+
// Row is above the visible area
546+
let topVal = rowTopRelativeToViewport - 30;
547+
if (topVal < 0) {
548+
topVal = 0;
548549
}
550+
viewport.scrollTo({ top: topVal });
551+
} else if (rowBottomRelativeToViewport + 5 > viewportScrollTop + viewportHeight) {
552+
// Row is below the visible area
553+
const topVal = rowBottomRelativeToViewport - viewportHeight + 5;
554+
viewport.scrollTo({ top: topVal });
549555
}
550-
// setIndexChangedFromClick(false);
551556
}, [focusIndex]);
552557

553558
const handleFileContextMenu = useCallback(
@@ -730,6 +735,7 @@ const TableRow = React.forwardRef(function ({
730735
return (
731736
<div
732737
className={clsx("dir-table-body-row", { focused: focusIndex === idx })}
738+
data-rowindex={idx}
733739
onDoubleClick={() => {
734740
const newFileName = row.getValue("path") as string;
735741
model.goHistory(newFileName);

staticcheck.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
checks = ["all", "-ST1005", "-QF1003", "-ST1000", "-ST1003"]
2+

0 commit comments

Comments
 (0)