mirror of
https://github.com/smolgrrr/TAO.git
synced 2024-09-20 09:21:25 +00:00
clean up
This commit is contained in:
parent
686875e203
commit
1d1e0b7f43
@ -4,9 +4,6 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@heroicons/react": "^2.0.18",
|
"@heroicons/react": "^2.0.18",
|
||||||
"@testing-library/jest-dom": "^5.17.0",
|
|
||||||
"@testing-library/react": "^13.4.0",
|
|
||||||
"@testing-library/user-event": "^13.5.0",
|
|
||||||
"@types/jest": "^27.5.2",
|
"@types/jest": "^27.5.2",
|
||||||
"@types/node": "^17.0.45",
|
"@types/node": "^17.0.45",
|
||||||
"@types/react": "^18.2.21",
|
"@types/react": "^18.2.21",
|
||||||
@ -17,10 +14,8 @@
|
|||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-linkify": "^1.0.0-alpha",
|
"react-linkify": "^1.0.0-alpha",
|
||||||
"react-pull-to-refresh": "^2.0.1",
|
|
||||||
"react-router-dom": "^6.15.0",
|
"react-router-dom": "^6.15.0",
|
||||||
"react-scripts": "5.0.1",
|
"react-scripts": "5.0.1",
|
||||||
"react-swipe": "^6.0.4",
|
|
||||||
"react-swipeable-views": "^0.14.0",
|
"react-swipeable-views": "^0.14.0",
|
||||||
"web-vitals": "^2.1.4",
|
"web-vitals": "^2.1.4",
|
||||||
"workbox-background-sync": "^6.6.0",
|
"workbox-background-sync": "^6.6.0",
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import { render, screen } from '@testing-library/react';
|
|
||||||
import App from './App';
|
|
||||||
|
|
||||||
test('renders learn react link', () => {
|
|
||||||
render(<App />);
|
|
||||||
const linkElement = screen.getByText(/learn react/i);
|
|
||||||
expect(linkElement).toBeInTheDocument();
|
|
||||||
});
|
|
@ -1,8 +1,8 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import PostCard from './PostCard/PostCard';
|
import PostCard from './PostCard/PostCard';
|
||||||
import NewThreadCard from './PostCard/NewThreadCard';
|
import NewThreadCard from './PostCard/NewThreadCard';
|
||||||
import { getPow } from '../utils/mine';
|
import { getPow } from '../utils/mine';
|
||||||
import { relayInit, Event } from 'nostr-tools';
|
import { Event } from 'nostr-tools';
|
||||||
import { subGlobalFeed } from '../utils/subscriptions';
|
import { subGlobalFeed } from '../utils/subscriptions';
|
||||||
import { uniqBy } from '../utils/utils';
|
import { uniqBy } from '../utils/utils';
|
||||||
|
|
||||||
@ -11,7 +11,6 @@ const Home = () => {
|
|||||||
|
|
||||||
const onEvent = (event: Event) => {
|
const onEvent = (event: Event) => {
|
||||||
setEvents((prevEvents) => [...prevEvents, event]);
|
setEvents((prevEvents) => [...prevEvents, event]);
|
||||||
console.log(`${event.id} ${event.kind} ${event.tags}`);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
import CardContainer from '../PostCard/CardContainer';
|
|
||||||
import { FolderIcon } from '@heroicons/react/24/outline';
|
|
||||||
import { parseContent } from '../../utils/content';
|
import { parseContent } from '../../utils/content';
|
||||||
import { Event } from 'nostr-tools';
|
import { Event } from 'nostr-tools';
|
||||||
import { nip19 } from 'nostr-tools';
|
|
||||||
import { useEffect, useState } from 'react';
|
|
||||||
import { subNote } from '../../utils/subscriptions';
|
|
||||||
import { getMetadata, uniqBy } from '../../utils/utils';
|
import { getMetadata, uniqBy } from '../../utils/utils';
|
||||||
import { getLinkPreview } from 'link-preview-js';
|
import ContentPreview from './TextModal';
|
||||||
import { subNoteOnce } from '../../utils/subscriptions';
|
|
||||||
|
|
||||||
const colorCombos = [
|
const colorCombos = [
|
||||||
'from-red-400 to-yellow-500',
|
'from-red-400 to-yellow-500',
|
||||||
@ -58,29 +52,14 @@ const timeAgo = (unixTime: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const QuoteEmbed = ({ event, metadata }: { event: Event, metadata: Event | null}) => {
|
const QuoteEmbed = ({ event, metadata }: { event: Event, metadata: Event | null}) => {
|
||||||
// Replace 10 with the actual number of comments for each post
|
|
||||||
const numberOfComments = 10;
|
|
||||||
const { comment, file } = parseContent(event);
|
const { comment, file } = parseContent(event);
|
||||||
const colorCombo = getColorFromHash(event.pubkey, colorCombos);
|
const colorCombo = getColorFromHash(event.pubkey, colorCombos);
|
||||||
const [isExpanded, setIsExpanded] = useState(false);
|
|
||||||
const truncatedComment = comment.slice(0, 240);
|
|
||||||
|
|
||||||
let metadataParsed = null;
|
let metadataParsed = null;
|
||||||
if (metadata !== null) {
|
if (metadata !== null) {
|
||||||
metadataParsed = getMetadata(metadata);
|
metadataParsed = getMetadata(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
const [linkPreview, setLinkPreview] = useState<LinkPreview | null>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const urls = comment.match(/\bhttps?:\/\/\S+/gi);
|
|
||||||
if (urls && urls.length > 0) {
|
|
||||||
getLinkPreview(urls[0])
|
|
||||||
.then((preview) => setLinkPreview(preview as LinkPreview))
|
|
||||||
.catch((error) => console.error(error));
|
|
||||||
}
|
|
||||||
}, [comment]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-1 bg-gradient-to-r from-black to-neutral-900 rounded-lg border border-neutral-800">
|
<div className="p-1 bg-gradient-to-r from-black to-neutral-900 rounded-lg border border-neutral-800">
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
@ -100,22 +79,7 @@ const QuoteEmbed = ({ event, metadata }: { event: Event, metadata: Event | null}
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mr-2 flex flex-col break-words">
|
<div className="mr-2 flex flex-col break-words">
|
||||||
{isExpanded ? comment : truncatedComment}
|
<ContentPreview key={event.id} comment={comment} />
|
||||||
{comment.length > 240 && (
|
|
||||||
<button className="text-gray-500">
|
|
||||||
... Read more
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
{linkPreview && linkPreview.images && linkPreview.images.length > 0 && (
|
|
||||||
<div className="link-preview p-1 bg-neutral-800 rounded-lg border border-neutral-800">
|
|
||||||
<a href={linkPreview.url} target="_blank" rel="noopener noreferrer" className="">
|
|
||||||
<img src={linkPreview.images[0]} alt={linkPreview.title} className="rounded-lg"/>
|
|
||||||
<div className="font-semibold text-xs text-gray-300">
|
|
||||||
{linkPreview.title}
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
{file !== "" && (
|
{file !== "" && (
|
||||||
<div className="file">
|
<div className="file">
|
||||||
@ -130,23 +94,4 @@ const QuoteEmbed = ({ event, metadata }: { event: Event, metadata: Event | null}
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
interface LinkPreview {
|
|
||||||
url: string;
|
|
||||||
title: string;
|
|
||||||
siteName?: string;
|
|
||||||
description?: string;
|
|
||||||
mediaType: string;
|
|
||||||
contentType?: string;
|
|
||||||
images: string[];
|
|
||||||
videos: {
|
|
||||||
url?: string;
|
|
||||||
secureUrl?: string;
|
|
||||||
type?: string;
|
|
||||||
width?: string;
|
|
||||||
height?: string;
|
|
||||||
[key: string]: any;
|
|
||||||
}[];
|
|
||||||
[key: string]: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default QuoteEmbed;
|
export default QuoteEmbed;
|
@ -1,8 +1,6 @@
|
|||||||
import QuoteEmbed from "./QuoteEmbed";
|
import QuoteEmbed from "./QuoteEmbed";
|
||||||
import { getLinkPreview } from 'link-preview-js';
|
|
||||||
import { Event } from 'nostr-tools';
|
import { Event } from 'nostr-tools';
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { getMetadata, uniqBy } from '../../utils/utils';
|
|
||||||
import { subNoteOnce } from '../../utils/subscriptions';
|
import { subNoteOnce } from '../../utils/subscriptions';
|
||||||
import { nip19 } from "nostr-tools";
|
import { nip19 } from "nostr-tools";
|
||||||
import LinkModal from "./LinkPreview";
|
import LinkModal from "./LinkPreview";
|
||||||
@ -16,14 +14,13 @@ const ContentPreview = ({ key, comment }: { key: string, comment: string }) => {
|
|||||||
// Define your callback function for subGlobalFeed
|
// Define your callback function for subGlobalFeed
|
||||||
const onEvent = (event: Event, relay: string) => {
|
const onEvent = (event: Event, relay: string) => {
|
||||||
setQuoteEvents((prevEvents) => [...prevEvents, event]);
|
setQuoteEvents((prevEvents) => [...prevEvents, event]);
|
||||||
console.log(event.id + ' ' + event.kind + ' ' + event.tags);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const findUrl = comment.match(/\bhttps?:\/\/\S+/gi);
|
const findUrl = comment.match(/\bhttps?:\/\/\S+/gi);
|
||||||
if (findUrl && findUrl.length > 0) {
|
if (findUrl && findUrl.length > 0) {
|
||||||
setUrl(findUrl[0])
|
setUrl(findUrl[0])
|
||||||
// setFinalComment(finalComment.replace(findUrl[0], '').trim())
|
setFinalComment(finalComment.replace(findUrl[0], '').trim())
|
||||||
}
|
}
|
||||||
|
|
||||||
const match = comment.match(/\bnostr:([a-z0-9]+)/i);
|
const match = comment.match(/\bnostr:([a-z0-9]+)/i);
|
||||||
@ -33,7 +30,7 @@ const ContentPreview = ({ key, comment }: { key: string, comment: string }) => {
|
|||||||
subNoteOnce(id_to_hex, onEvent);
|
subNoteOnce(id_to_hex, onEvent);
|
||||||
setFinalComment(finalComment.replace('nostr:'+nostrQuoteID, '').trim())
|
setFinalComment(finalComment.replace('nostr:'+nostrQuoteID, '').trim())
|
||||||
}
|
}
|
||||||
}, [comment]);
|
}, [comment, finalComment]);
|
||||||
|
|
||||||
const getMetadataEvent = (event: Event) => {
|
const getMetadataEvent = (event: Event) => {
|
||||||
const metadataEvent = quoteEvents.find(e => e.pubkey === event.pubkey && e.kind === 0);
|
const metadataEvent = quoteEvents.find(e => e.pubkey === event.pubkey && e.kind === 0);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import CardContainer from './CardContainer';
|
import CardContainer from './CardContainer';
|
||||||
import { ArrowUpTrayIcon, CpuChipIcon } from '@heroicons/react/24/outline';
|
import { ArrowUpTrayIcon, CpuChipIcon } from '@heroicons/react/24/outline';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Event, generatePrivateKey, getPublicKey, finishEvent, relayInit } from 'nostr-tools';
|
import { generatePrivateKey, getPublicKey, finishEvent } from 'nostr-tools';
|
||||||
import { minePow } from '../../utils/mine';
|
import { minePow } from '../../utils/mine';
|
||||||
import { publish } from '../../utils/relays';
|
import { publish } from '../../utils/relays';
|
||||||
import NostrImg from '../../utils/ImgUpload';
|
import NostrImg from '../../utils/ImgUpload';
|
||||||
|
@ -3,7 +3,7 @@ import { FolderIcon } from '@heroicons/react/24/outline';
|
|||||||
import { parseContent } from '../../utils/content';
|
import { parseContent } from '../../utils/content';
|
||||||
import { Event } from 'nostr-tools';
|
import { Event } from 'nostr-tools';
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
import { getMetadata, uniqBy } from '../../utils/utils';
|
import { getMetadata } from '../../utils/utils';
|
||||||
import ContentPreview from'../Modals/TextModal';
|
import ContentPreview from'../Modals/TextModal';
|
||||||
|
|
||||||
const colorCombos = [
|
const colorCombos = [
|
||||||
@ -89,7 +89,7 @@ const PostCard = ({ key, event, metadata, replyCount }: { key: string, event: Ev
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mr-2 flex flex-col break-words">
|
<div className="mr-2 flex flex-col break-words">
|
||||||
<ContentPreview key={key} comment={comment} />
|
<ContentPreview key={event.id} comment={comment} />
|
||||||
</div>
|
</div>
|
||||||
{file !== "" && (
|
{file !== "" && (
|
||||||
<div className="file">
|
<div className="file">
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState } from 'react';
|
||||||
import {generatePrivateKey, getPublicKey} from 'nostr-tools';
|
|
||||||
// import {powEvent} from './system';
|
// import {powEvent} from './system';
|
||||||
// import {publish} from './relays';
|
// import {publish} from './relays';
|
||||||
|
|
||||||
|
@ -2,11 +2,7 @@ import CardContainer from '../PostCard/CardContainer';
|
|||||||
import { FolderIcon } from '@heroicons/react/24/outline';
|
import { FolderIcon } from '@heroicons/react/24/outline';
|
||||||
import { parseContent } from '../../utils/content';
|
import { parseContent } from '../../utils/content';
|
||||||
import { Event } from 'nostr-tools';
|
import { Event } from 'nostr-tools';
|
||||||
import { nip19 } from 'nostr-tools';
|
import { getMetadata } from '../../utils/utils';
|
||||||
import { useEffect, useState } from 'react';
|
|
||||||
import { subNote } from '../../utils/subscriptions';
|
|
||||||
import { getMetadata, uniqBy } from '../../utils/utils';
|
|
||||||
import { getLinkPreview } from 'link-preview-js';
|
|
||||||
import ContentPreview from '../Modals/TextModal';
|
import ContentPreview from '../Modals/TextModal';
|
||||||
|
|
||||||
const colorCombos = [
|
const colorCombos = [
|
||||||
@ -58,29 +54,14 @@ const timeAgo = (unixTime: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const OPCard = ({ event, metadata, replyCount }: { event: Event, metadata: Event | null, replyCount: number}) => {
|
const OPCard = ({ event, metadata, replyCount }: { event: Event, metadata: Event | null, replyCount: number}) => {
|
||||||
// Replace 10 with the actual number of comments for each post
|
|
||||||
const numberOfComments = 10;
|
|
||||||
const { comment, file } = parseContent(event);
|
const { comment, file } = parseContent(event);
|
||||||
const colorCombo = getColorFromHash(event.pubkey, colorCombos);
|
const colorCombo = getColorFromHash(event.pubkey, colorCombos);
|
||||||
const [isExpanded, setIsExpanded] = useState(false);
|
|
||||||
const truncatedComment = comment.slice(0, 240);
|
|
||||||
|
|
||||||
let metadataParsed = null;
|
let metadataParsed = null;
|
||||||
if (metadata !== null) {
|
if (metadata !== null) {
|
||||||
metadataParsed = getMetadata(metadata);
|
metadataParsed = getMetadata(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
const [linkPreview, setLinkPreview] = useState<LinkPreview | null>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const urls = comment.match(/\bhttps?:\/\/\S+/gi);
|
|
||||||
if (urls && urls.length > 0) {
|
|
||||||
getLinkPreview(urls[0])
|
|
||||||
.then((preview) => setLinkPreview(preview as LinkPreview))
|
|
||||||
.catch((error) => console.error(error));
|
|
||||||
}
|
|
||||||
}, [comment]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CardContainer>
|
<CardContainer>
|
||||||
|
@ -3,8 +3,6 @@ import { FolderIcon } from '@heroicons/react/24/outline';
|
|||||||
import { parseContent } from '../../utils/content';
|
import { parseContent } from '../../utils/content';
|
||||||
import { Event } from 'nostr-tools';
|
import { Event } from 'nostr-tools';
|
||||||
import { nip19 } from 'nostr-tools';
|
import { nip19 } from 'nostr-tools';
|
||||||
import { useEffect, useState } from 'react';
|
|
||||||
import { subNote } from '../../utils/subscriptions';
|
|
||||||
import { getMetadata, uniqBy } from '../../utils/utils';
|
import { getMetadata, uniqBy } from '../../utils/utils';
|
||||||
import ContentPreview from '../Modals/TextModal';
|
import ContentPreview from '../Modals/TextModal';
|
||||||
|
|
||||||
|
@ -3,11 +3,9 @@ import { useState } from "react";
|
|||||||
import { Event, nip19 } from "nostr-tools"
|
import { Event, nip19 } from "nostr-tools"
|
||||||
import { subNote } from '../../utils/subscriptions';
|
import { subNote } from '../../utils/subscriptions';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import PostCard from '../PostCard/PostCard';
|
|
||||||
import { uniqBy } from '../../utils/utils';
|
import { uniqBy } from '../../utils/utils';
|
||||||
import { DocumentTextIcon, FolderPlusIcon } from '@heroicons/react/24/outline';
|
import { DocumentTextIcon, FolderPlusIcon } from '@heroicons/react/24/outline';
|
||||||
import { ArrowUpTrayIcon, CpuChipIcon } from '@heroicons/react/24/outline';
|
import { generatePrivateKey, getPublicKey, finishEvent } from 'nostr-tools';
|
||||||
import { generatePrivateKey, getPublicKey, finishEvent, relayInit } from 'nostr-tools';
|
|
||||||
import { minePow } from '../../utils/mine';
|
import { minePow } from '../../utils/mine';
|
||||||
import { publish } from '../../utils/relays';
|
import { publish } from '../../utils/relays';
|
||||||
import ThreadPost from './ThreadPost';
|
import ThreadPost from './ThreadPost';
|
||||||
@ -28,7 +26,6 @@ const Thread = () => {
|
|||||||
// Define your callback function for subGlobalFeed
|
// Define your callback function for subGlobalFeed
|
||||||
const onEvent = (event: Event, relay: string) => {
|
const onEvent = (event: Event, relay: string) => {
|
||||||
setEvents((prevEvents) => [...prevEvents, event]);
|
setEvents((prevEvents) => [...prevEvents, event]);
|
||||||
console.log(event.id + ' ' + event.kind + ' ' + event.tags);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { ArrowUpTrayIcon, CpuChipIcon } from '@heroicons/react/24/outline';
|
import { ArrowUpTrayIcon, CpuChipIcon } from '@heroicons/react/24/outline';
|
||||||
import { generatePrivateKey, getPublicKey, finishEvent, relayInit } from 'nostr-tools';
|
import { generatePrivateKey, getPublicKey, finishEvent } from 'nostr-tools';
|
||||||
import { minePow } from '../../utils/mine';
|
import { minePow } from '../../utils/mine';
|
||||||
import { publish } from '../../utils/relays';
|
import { publish } from '../../utils/relays';
|
||||||
import NostrImg from '../../utils/ImgUpload';
|
import NostrImg from '../../utils/ImgUpload';
|
||||||
|
@ -3,7 +3,6 @@ import ReactDOM from 'react-dom/client';
|
|||||||
import './index.css';
|
import './index.css';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import * as serviceWorkerRegistration from './serviceWorkerRegistration';
|
import * as serviceWorkerRegistration from './serviceWorkerRegistration';
|
||||||
import reportWebVitals from './reportWebVitals';
|
|
||||||
|
|
||||||
const root = ReactDOM.createRoot(
|
const root = ReactDOM.createRoot(
|
||||||
document.getElementById('root') as HTMLElement
|
document.getElementById('root') as HTMLElement
|
||||||
@ -18,8 +17,3 @@ root.render(
|
|||||||
// unregister() to register() below. Note this comes with some pitfalls.
|
// unregister() to register() below. Note this comes with some pitfalls.
|
||||||
// Learn more about service workers: https://cra.link/PWA
|
// Learn more about service workers: https://cra.link/PWA
|
||||||
serviceWorkerRegistration.unregister();
|
serviceWorkerRegistration.unregister();
|
||||||
|
|
||||||
// If you want to start measuring performance in your app, pass a function
|
|
||||||
// to log results (for example: reportWebVitals(console.log))
|
|
||||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
||||||
reportWebVitals();
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
import { ReportHandler } from 'web-vitals';
|
|
||||||
|
|
||||||
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
|
||||||
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
||||||
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
|
||||||
getCLS(onPerfEntry);
|
|
||||||
getFID(onPerfEntry);
|
|
||||||
getFCP(onPerfEntry);
|
|
||||||
getLCP(onPerfEntry);
|
|
||||||
getTTFB(onPerfEntry);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default reportWebVitals;
|
|
@ -1,6 +1,5 @@
|
|||||||
import {sub, subOnce, unsubAll} from './relays';
|
import {sub, subOnce, unsubAll} from './relays';
|
||||||
import { Event } from 'nostr-tools';
|
import { Event } from 'nostr-tools';
|
||||||
import { getPow } from './mine';
|
|
||||||
|
|
||||||
type SubCallback = (
|
type SubCallback = (
|
||||||
event: Event,
|
event: Event,
|
||||||
|
Loading…
Reference in New Issue
Block a user