diff --git a/client/package.json b/client/package.json
index 2e01785..88dbeb1 100644
--- a/client/package.json
+++ b/client/package.json
@@ -15,8 +15,10 @@
"nostr-tools": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0",
+ "react-pull-to-refresh": "^2.0.1",
"react-router-dom": "^6.15.0",
"react-scripts": "5.0.1",
+ "react-swipe": "^6.0.4",
"react-swipeable-views": "^0.14.0",
"web-vitals": "^2.1.4",
"workbox-background-sync": "^6.6.0",
diff --git a/client/src/components/PostCard/CardContainer.tsx b/client/src/components/PostCard/CardContainer.tsx
index ff84b3d..cc0467b 100644
--- a/client/src/components/PostCard/CardContainer.tsx
+++ b/client/src/components/PostCard/CardContainer.tsx
@@ -2,7 +2,7 @@ import { PropsWithChildren } from 'react';
export default function CardContainer({ children }: PropsWithChildren) {
return (
-
+
);
diff --git a/client/src/components/PostCard/NewThreadCard.tsx b/client/src/components/PostCard/NewThreadCard.tsx
index 83c0cba..97c59d8 100644
--- a/client/src/components/PostCard/NewThreadCard.tsx
+++ b/client/src/components/PostCard/NewThreadCard.tsx
@@ -1,15 +1,17 @@
import CardContainer from './CardContainer';
import { ArrowUpTrayIcon, CpuChipIcon } from '@heroicons/react/24/outline';
import { useState } from 'react';
-import { Event, generatePrivateKey, getPublicKey, finishEvent, relayInit} from 'nostr-tools';
+import { Event, generatePrivateKey, getPublicKey, finishEvent, relayInit } from 'nostr-tools';
import { minePow } from '../../utils/mine';
import { publish } from '../../utils/relays';
+import NostrImg from '../../utils/ImgUpload';
const difficulty = 20
const NewThreadCard: React.FC = () => {
const [comment, setComment] = useState("");
-
+ const [file, setFile] = useState("");
+
const handleSubmit = async (event: React.FormEvent
) => {
event.preventDefault();
let sk = generatePrivateKey();
@@ -18,73 +20,98 @@ const NewThreadCard: React.FC = () => {
const event = minePow({
kind: 1,
tags: [],
- content: comment,
+ content: comment + " " + file,
created_at: Math.floor(Date.now() / 1000),
pubkey: getPublicKey(sk),
}, difficulty);
const signedEvent = finishEvent(event, sk);
await publish(signedEvent);
- console.log(signedEvent.id);
-
+
+ setComment("")
+ setFile("")
} catch (error) {
setComment(comment + " " + error);
}
};
- // async function attachFile(file_input: File | null) {
- // try {
- // if (file_input) {
- // const rx = await NostrImg(file_input);
- // if (rx.url) {
- // setComment(comment + " " + rx.url);
- // } else if (rx?.error) {
- // setComment(comment + " " + rx.error);
- // }
- // }
- // } catch (error: unknown) {
- // if (error instanceof Error) {
- // setComment(comment + " " + error?.message);
- // }
- // }
- // }
+ async function attachFile(file_input: File | null) {
+ try {
+ if (file_input) {
+ const rx = await NostrImg(file_input);
+ if (rx.url) {
+ setFile(rx.url);
+ } else if (rx?.error) {
+ setFile(rx.error);
+ }
+ }
+ } catch (error: unknown) {
+ if (error instanceof Error) {
+ setFile(error?.message);
+ }
+ }
+ }
return (
<>
-