fix: file paths

This commit is contained in:
Kieran 2023-11-27 13:39:30 +00:00
parent d2b8484697
commit 0e04cf827d
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
2 changed files with 224 additions and 220 deletions

View File

@ -7,7 +7,8 @@
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
"preview": "vite preview",
"deploy": "yarn build && yarn dlx wrangler pages deploy dist"
},
"dependencies": {
"@noble/hashes": "^1.3.2",

View File

@ -8,6 +8,7 @@ import * as bencode from "../bencode";
import { sha1 } from "@noble/hashes/sha1";
import { bytesToHex } from "@noble/hashes/utils";
import { SnortContext } from "@snort/system-react";
import { useNavigate } from "react-router-dom";
async function openFile(): Promise<File | undefined> {
return new Promise((resolve) => {
@ -45,6 +46,7 @@ async function openFile(): Promise<File | undefined> {
export function NewPage() {
const login = useLogin();
const system = useContext(SnortContext);
const navigate = useNavigate();
const [obj, setObj] = useState({
name: "",
@ -78,7 +80,7 @@ export function NewPage() {
tags: [],
files: (info.files ?? [{ length: info.length, path: [info.name] }]).map((a) => ({
size: a.length,
name: dec.decode(a.path[0]),
name: a.path.map(b => dec.decode(b)).join("/"),
})),
});
}
@ -107,6 +109,7 @@ export function NewPage() {
if (ev) {
await system.BroadcastEvent(ev);
}
navigate("/")
}
function renderCategories(a: Category, tags: Array<string>): ReactNode {