diff --git a/src/main.ts b/src/main.ts index a50acf6..b16eb6e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -35,7 +35,7 @@ const createWindow = () => { mainWindow.loadFile(join(__dirname, "../renderer/index.html")); } - mainWindow.webContents.openDevTools({ mode: "detach" }); + // mainWindow.webContents.openDevTools({ mode: "detach" }); }; app.whenReady().then(() => { diff --git a/src/shared/routers/node.ts b/src/shared/routers/node.ts index 795c650..2c1b691 100644 --- a/src/shared/routers/node.ts +++ b/src/shared/routers/node.ts @@ -1,11 +1,18 @@ import { publicProcedure, router } from "@src/trpc"; import { createWriteStream, readFileSync } from "node:fs"; import { z } from "zod"; +import { matchFileType } from "../utils"; function parseFilePath(path: string) { + const fileExt = path.match(/\.[^/.]+$/)?.[0].split(".")[1]; + + const matchedFileType = matchFileType(fileExt || ""); + + console.log(fileExt); + return { fileName: "", - fileType: "", + fileType: matchedFileType, buffer: readFileSync(path), }; } diff --git a/src/shared/types.ts b/src/shared/types.ts index d896bf8..13b7795 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -64,3 +64,9 @@ export type EventTypes = { packet: Message; }; }; + +export enum FileTypes { + MD = "md", + TXT = "txt", + DOCX = "docx", +} diff --git a/src/shared/utils.ts b/src/shared/utils.ts index a0d6ff6..63ee16a 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -5,6 +5,7 @@ import { uniqueNamesGenerator, } from "unique-names-generator"; import { v4 } from "uuid"; +import { FileTypes } from "./types"; export function generateRandomName() { const randomName = uniqueNamesGenerator({ @@ -20,4 +21,24 @@ export function generateAppId() { return v4(); } -export const randomNumber = () => Math.floor(Math.random() * 250); +export const randomNumber = () => + Math.floor((Math.random() * window.innerWidth) / 2); + +export const randomNumberfromInterval = (min: number, max: number) => + Math.floor(Math.random() * (max - min + 1) + min); + +export const matchFileType = (fileExt: string) => { + if (fileExt === FileTypes.MD) { + return FileTypes.MD; + } + + if (fileExt === FileTypes.DOCX) { + return FileTypes.DOCX; + } + + if (fileExt === FileTypes.TXT) { + return FileTypes.TXT; + } + + return null; +}; diff --git a/src/web/components/Layout.tsx b/src/web/components/Layout.tsx index acff945..7ce93af 100644 --- a/src/web/components/Layout.tsx +++ b/src/web/components/Layout.tsx @@ -48,7 +48,7 @@ export default function Layout({ children }: LayoutProps) { width="100%" grow="1" direction="column" - className="transition h-screen" + className="transition h-screen transition" > randomNumber(), []); + const left = useMemo(() => randomNumber(), []); + const send = useCallback(() => { sendFiles({ destination: node.connectionId, @@ -29,19 +26,17 @@ export default function DeviceInfo({ node }: Props) { return ( - } + src="https://source.boringavatars.com/" + variant="soft" + className="absolute shadow-xl cursor-pointer border-1 border-solid border-zinc-200 dark:border-zinc-800" + radius="full" style={{ top: `${top}px`, left: `${left}px`, }} - > - default_image - + /> @@ -52,12 +47,12 @@ export default function DeviceInfo({ node }: Props) { width="100%" justify="between" > - + Device Name - {node.nodeName} + {node.nodeName} - + {/* {isSaved.get() && ( - + */} @@ -102,7 +97,6 @@ export default function DeviceInfo({ node }: Props) { > Send - )} diff --git a/src/web/routes/index.tsx b/src/web/routes/index.tsx index 46672fc..5e58028 100644 --- a/src/web/routes/index.tsx +++ b/src/web/routes/index.tsx @@ -43,6 +43,13 @@ function Index() { nodeName: generateRandomName(), }} /> + );