From 41b8ff40c628c7420932be489aad4e0b02e48a01 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Wed, 20 Jul 2022 19:41:30 +0300 Subject: [PATCH] fix: sign-event api working --- api/functions/sign-event/sign-event.js | 5 +---- .../Components/Comments/AddComment/AddComment.tsx | 2 +- .../Components/Comments/CommentCard/CommentCard.tsx | 5 +++-- .../Comments/CommentsSection/comments.worker.ts | 11 ++++++----- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/api/functions/sign-event/sign-event.js b/api/functions/sign-event/sign-event.js index e8be0f8..bd9ab60 100644 --- a/api/functions/sign-event/sign-event.js +++ b/api/functions/sign-event/sign-event.js @@ -9,7 +9,6 @@ const { prisma } = require('../../prisma'); const signEvent = async (req, res) => { - console.log(req.body); try { const userPubKey = await extractKeyFromCookie(req.headers.cookie ?? req.headers.Cookie) const user = await getUserByPubKey(userPubKey); @@ -40,13 +39,11 @@ const signEvent = async (req, res) => { pubkey, content, tags, - created_at: Date.now(), + created_at: Math.round(Date.now() / 1000), } event.sig = await signNostrEvent(event, prvkey); - console.log(event); - return res .status(200) .json({ event }); diff --git a/src/features/Posts/Components/Comments/AddComment/AddComment.tsx b/src/features/Posts/Components/Comments/AddComment/AddComment.tsx index cd2090d..f2046e1 100644 --- a/src/features/Posts/Components/Comments/AddComment/AddComment.tsx +++ b/src/features/Posts/Components/Comments/AddComment/AddComment.tsx @@ -87,7 +87,7 @@ export default function AddComment({ initialContent, placeholder, name, autoFocu const submitComment = () => { onSubmit?.(valueRef.current); - // manager.view.updateState(manager.createState({ content: manager.createEmptyDoc() })) + manager.view.updateState(manager.createState({ content: manager.createEmptyDoc() })) } diff --git a/src/features/Posts/Components/Comments/CommentCard/CommentCard.tsx b/src/features/Posts/Components/Comments/CommentCard/CommentCard.tsx index cc7813d..4c26ed6 100644 --- a/src/features/Posts/Components/Comments/CommentCard/CommentCard.tsx +++ b/src/features/Posts/Components/Comments/CommentCard/CommentCard.tsx @@ -1,3 +1,4 @@ +import { marked } from "marked"; import { BiComment } from "react-icons/bi"; import VotesCount from "src/Components/VotesCount/VotesCount"; import Header from "src/features/Posts/Components/PostCard/Header/Header"; @@ -13,8 +14,8 @@ export default function CommentCard({ comment, onReply }: Props) { return (
-

- {comment.body} +

+

diff --git a/src/features/Posts/Components/Comments/CommentsSection/comments.worker.ts b/src/features/Posts/Components/Comments/CommentsSection/comments.worker.ts index 5dd73f0..3a6bc74 100644 --- a/src/features/Posts/Components/Comments/CommentsSection/comments.worker.ts +++ b/src/features/Posts/Components/Comments/CommentsSection/comments.worker.ts @@ -77,8 +77,11 @@ const getSignedEvents = async (event: any) => { const res = await fetch(CONSTS.apiEndpoint + '/sign-event', { method: "post", body: JSON.stringify({ event }), - credentials: 'include' - }) + credentials: 'include', + headers: { + 'Content-Type': 'application/json' + }, + }); const data = await res.json() return data.event; } @@ -110,8 +113,6 @@ export async function post(data: string, filter: string) { tags: [['r', filter]], content: data }) as NostrEvent; - console.log(event); - return; } catch (error) { alert("Couldn't sign the object successfully...") return; @@ -197,7 +198,7 @@ export async function constructTree() { // (nothing for now -:-) // Turn the top roots replies into a sorted array - const sortedTree = Object.values(eventsTree).sort((a, b) => a.created_at - b.created_at) + const sortedTree = Object.values(eventsTree).sort((a, b) => b.created_at - a.created_at) // Publish the new tree. return sortedTree;