From 27fe32d7483f5d7444207c0723ecd87e4fa7fc3b Mon Sep 17 00:00:00 2001
From: Ren Amamiya <123083837+reyamir@users.noreply.github.com>
Date: Wed, 22 Mar 2023 09:57:12 +0700
Subject: [PATCH] fixed note
---
src/components/note/connector.tsx | 2 +-
src/components/note/content/index.tsx | 9 ++++-----
src/components/note/index.tsx | 15 +++++++--------
src/components/note/root.tsx | 2 +-
4 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/src/components/note/connector.tsx b/src/components/note/connector.tsx
index 16735a17..5f2ff1cb 100644
--- a/src/components/note/connector.tsx
+++ b/src/components/note/connector.tsx
@@ -25,7 +25,7 @@ export const NoteConnector = memo(function NoteConnector() {
// insert to local database
await db.execute(
'INSERT OR IGNORE INTO cache_notes (id, pubkey, created_at, kind, content, tags) VALUES (?, ?, ?, ?, ?, ?);',
- [event.id, event.pubkey, event.created_at, event.kind, event.content, String(event.tags)]
+ [event.id, event.pubkey, event.created_at, event.kind, event.content, JSON.stringify(event.tags)]
);
},
[db]
diff --git a/src/components/note/content/index.tsx b/src/components/note/content/index.tsx
index 2dec501c..6f84a640 100644
--- a/src/components/note/content/index.tsx
+++ b/src/components/note/content/index.tsx
@@ -10,8 +10,7 @@ export const Content = memo(function Content({ data }: { data: any }) {
const content = useMemo(() => {
let parsedContent;
// get data tags
- const tags = String(data.tags).replaceAll("'", '"');
- const parseTags = JSON.parse(tags);
+ const tags = JSON.parse(data.tags);
// remove all image urls
parsedContent = data.content.replace(/(https?:\/\/.*\.(jpg|jpeg|gif|png|webp|mp4|webm)((\?.*)$|$))/gim, '');
// handle urls
@@ -27,10 +26,10 @@ export const Content = memo(function Content({ data }: { data: any }) {
));
// handle mentions
- if (parseTags.length > 0) {
+ if (tags.length > 0) {
parsedContent = reactStringReplace(parsedContent, /\#\[(\d+)\]/gm, (match, i) => {
- if (parseTags[match][0] === 'p') {
- return