mirror of
https://github.com/smolgrrr/TAO.git
synced 2024-09-20 01:11:25 +00:00
add hashtags bar to feeds
This commit is contained in:
parent
47596c13c1
commit
c61a46a953
16
client/src/components/modals/HashtagBar.tsx
Normal file
16
client/src/components/modals/HashtagBar.tsx
Normal file
@ -0,0 +1,16 @@
|
||||
const DefaultHashtags = ['asknostr', 'kinostr', 'technology'];
|
||||
|
||||
export default function HashtagBar() {
|
||||
|
||||
return (
|
||||
<div className="flex justify-between items-center">
|
||||
<ul className='py-1 flex space-x-4 text-xs text-neutral-400 m-auto'>
|
||||
{DefaultHashtags.map((hashtag, index) => (
|
||||
<li key={index}>
|
||||
<a href={`/hashtag/${hashtag}`} className='hover:underline'>#{hashtag}</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
@ -22,20 +22,20 @@ const checkMedia = async (url: string) => {
|
||||
});
|
||||
const nsfwResult = await nsfwResponse.json();
|
||||
|
||||
// PicPurify gore check
|
||||
const picpurifyResponse = await fetch('https://www.picpurify.com/analyse/1.1', {
|
||||
method: 'POST',
|
||||
body: new URLSearchParams({
|
||||
'API_KEY': picpurifyApiKey,
|
||||
'task': 'gore_moderation',
|
||||
'url_image': url
|
||||
})
|
||||
});
|
||||
const picpurifyResult = await picpurifyResponse.json();
|
||||
// // PicPurify gore check
|
||||
// const picpurifyResponse = await fetch('https://www.picpurify.com/analyse/1.1', {
|
||||
// method: 'POST',
|
||||
// body: new URLSearchParams({
|
||||
// 'API_KEY': picpurifyApiKey,
|
||||
// 'task': 'gore_moderation',
|
||||
// 'url_image': url
|
||||
// })
|
||||
// });
|
||||
// const picpurifyResult = await picpurifyResponse.json();
|
||||
|
||||
return {
|
||||
nsfw: nsfwResult,
|
||||
gore: picpurifyResult
|
||||
// gore: picpurifyResult
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error checking media:", error);
|
||||
@ -63,7 +63,7 @@ const RenderMedia = ({ files }: { files: string[] }) => {
|
||||
...prev,
|
||||
[file]: {
|
||||
nsfwLabel: result.nsfw?.data?.predictedLabel,
|
||||
goreContent: result.gore?.gore_moderation?.gore_content
|
||||
// goreContent: result.gore?.gore_moderation?.gore_content
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
@ -85,7 +85,7 @@ const RenderMedia = ({ files }: { files: string[] }) => {
|
||||
const mediaCheckResult = mediaCheckResults[file];
|
||||
|
||||
// Check for both NSFW and gore content
|
||||
if (mediaCheckResult && (mediaCheckResult.nsfwLabel !== 'neutral' || mediaCheckResult.goreContent)) {
|
||||
if (mediaCheckResult && (mediaCheckResult.nsfwLabel !== 'neutral')) {
|
||||
return (
|
||||
<div>
|
||||
<p className="text-center text-red-500 text-xs">Attached media has been flagged as not safe for work or contains gore.</p>
|
||||
@ -93,7 +93,7 @@ const RenderMedia = ({ files }: { files: string[] }) => {
|
||||
);
|
||||
}
|
||||
|
||||
if (file && (file.endsWith(".mp4") || file.endsWith(".webm")) && mediaCheckResult && mediaCheckResult.nsfwLabel === 'neutral') {
|
||||
if (file && (file.endsWith(".mp4") || file.endsWith(".webm"))) {
|
||||
return (
|
||||
<video
|
||||
key={index}
|
||||
|
@ -2,6 +2,7 @@ import PostCard from "../modals/PostCard";
|
||||
import NewNoteCard from "../forms/PostFormCard";
|
||||
import { useParams } from "react-router-dom";
|
||||
import useProcessedEvents from "../../hooks/processedEvents";
|
||||
import HashtagBar from "../modals/HashtagBar";
|
||||
|
||||
const DEFAULT_DIFFICULTY = 0;
|
||||
|
||||
@ -15,6 +16,7 @@ const HashtagPage = () => {
|
||||
<main className="text-white mb-20">
|
||||
<div className="w-full px-4 sm:px-0 sm:max-w-xl mx-auto my-2">
|
||||
<NewNoteCard hashtag={id as string} />
|
||||
<HashtagBar />
|
||||
</div>
|
||||
<div className="grid grid-cols-1 max-w-xl mx-auto gap-1 px-4">
|
||||
{processedEvents.map((event) =>
|
||||
|
@ -3,6 +3,7 @@ import { DEFAULT_DIFFICULTY } from "../../config";
|
||||
import PostCard from "../modals/PostCard";
|
||||
import { useState, useEffect, useMemo } from "react";
|
||||
import useProcessedEvents from "../../hooks/processedEvents";
|
||||
import HashtagBar from "../modals/HashtagBar";
|
||||
|
||||
const Home = () => {
|
||||
const filterDifficulty = useMemo(() => {
|
||||
@ -25,6 +26,7 @@ const Home = () => {
|
||||
<main className="text-white mb-20">
|
||||
<div className="w-full px-4 sm:px-0 sm:max-w-xl mx-auto my-2">
|
||||
<NewNoteCard />
|
||||
<HashtagBar />
|
||||
</div>
|
||||
<div className={`grid grid-cols-1 max-w-xl mx-auto gap-1 ${isAnimating ? 'animate-pulse' : ''}`}>
|
||||
{processedEvents.map((event) => (
|
||||
|
@ -56,7 +56,7 @@ const Thread = () => {
|
||||
return (
|
||||
<>
|
||||
<main className="bg-black text-white min-h-screen">
|
||||
<div className="w-full px-4 sm:px-0 sm:max-w-xl mx-auto my-2">
|
||||
<div className="w-full sm:px-0 sm:max-w-xl mx-auto my-2">
|
||||
{earlierEvents
|
||||
.filter(event => event.kind === 1)
|
||||
.sort((a, b) => a.created_at - b.created_at).map((event, index) => (
|
||||
|
Loading…
Reference in New Issue
Block a user