refactor: remove size tag

This commit is contained in:
Kieran 2023-11-27 17:19:27 +00:00
parent f5784534d6
commit b4cc59d25f
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
4 changed files with 2 additions and 4 deletions

View File

@ -4,7 +4,6 @@
"content": "<long-description-pre-formatted>",
"tags": [
["title", "<torrent-title>"],
["size", "<size-in-bytes>"],
["btih", "<bittorrent-info-hash>"],
["t", "<top-level-tag>"],
["t", "(optional)<second-level-tag>"],

View File

@ -31,7 +31,7 @@ export function TorrentList({ items }: { items: Array<TaggedNostrEvent> }) {
function TorrentTableEntry({ item }: { item: TaggedNostrEvent }) {
const profile = useUserProfile(item.pubkey);
const name = item.tags.find((a) => a[0] === "title")?.at(1);
const size = Number(item.tags.find((a) => a[0] === "size")?.at(1));
const size = item.tags.filter(a => a[0] === "file").map(a => Number(a[2])).reduce((acc, v) => acc += v, 0);
const npub = hexToBech32("npub", item.pubkey);
return (
<tr>

View File

@ -90,7 +90,6 @@ export function NewPage() {
.kind(TorrentKind)
.content(obj.desc)
.tag(["title", obj.name])
.tag(["size", String(obj.files.reduce((acc, v) => (acc += v.size), 0))])
.tag(["btih", obj.btih]);
obj.tags.forEach((t) => v.tag(["t", t]));

View File

@ -29,7 +29,7 @@ export function TorrentDetail({ item }: { item: TaggedNostrEvent }) {
const login = useLogin();
const navigate = useNavigate();
const name = item.tags.find((a) => a[0] === "title")?.at(1);
const size = Number(item.tags.find((a) => a[0] === "size")?.at(1));
const size = item.tags.filter(a => a[0] === "file").map(a => Number(a[2])).reduce((acc, v) => acc += v, 0);
const files = item.tags.filter((a) => a[0] === "file");
const tags = item.tags.filter((a) => a[0] === "t").map((a) => a[1]);