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();
|
const nsfwResult = await nsfwResponse.json();
|
||||||
|
|
||||||
// PicPurify gore check
|
// // PicPurify gore check
|
||||||
const picpurifyResponse = await fetch('https://www.picpurify.com/analyse/1.1', {
|
// const picpurifyResponse = await fetch('https://www.picpurify.com/analyse/1.1', {
|
||||||
method: 'POST',
|
// method: 'POST',
|
||||||
body: new URLSearchParams({
|
// body: new URLSearchParams({
|
||||||
'API_KEY': picpurifyApiKey,
|
// 'API_KEY': picpurifyApiKey,
|
||||||
'task': 'gore_moderation',
|
// 'task': 'gore_moderation',
|
||||||
'url_image': url
|
// 'url_image': url
|
||||||
})
|
// })
|
||||||
});
|
// });
|
||||||
const picpurifyResult = await picpurifyResponse.json();
|
// const picpurifyResult = await picpurifyResponse.json();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
nsfw: nsfwResult,
|
nsfw: nsfwResult,
|
||||||
gore: picpurifyResult
|
// gore: picpurifyResult
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error checking media:", error);
|
console.error("Error checking media:", error);
|
||||||
@ -63,7 +63,7 @@ const RenderMedia = ({ files }: { files: string[] }) => {
|
|||||||
...prev,
|
...prev,
|
||||||
[file]: {
|
[file]: {
|
||||||
nsfwLabel: result.nsfw?.data?.predictedLabel,
|
nsfwLabel: result.nsfw?.data?.predictedLabel,
|
||||||
goreContent: result.gore?.gore_moderation?.gore_content
|
// goreContent: result.gore?.gore_moderation?.gore_content
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
@ -85,7 +85,7 @@ const RenderMedia = ({ files }: { files: string[] }) => {
|
|||||||
const mediaCheckResult = mediaCheckResults[file];
|
const mediaCheckResult = mediaCheckResults[file];
|
||||||
|
|
||||||
// Check for both NSFW and gore content
|
// Check for both NSFW and gore content
|
||||||
if (mediaCheckResult && (mediaCheckResult.nsfwLabel !== 'neutral' || mediaCheckResult.goreContent)) {
|
if (mediaCheckResult && (mediaCheckResult.nsfwLabel !== 'neutral')) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<p className="text-center text-red-500 text-xs">Attached media has been flagged as not safe for work or contains gore.</p>
|
<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 (
|
return (
|
||||||
<video
|
<video
|
||||||
key={index}
|
key={index}
|
||||||
|
@ -2,6 +2,7 @@ import PostCard from "../modals/PostCard";
|
|||||||
import NewNoteCard from "../forms/PostFormCard";
|
import NewNoteCard from "../forms/PostFormCard";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import useProcessedEvents from "../../hooks/processedEvents";
|
import useProcessedEvents from "../../hooks/processedEvents";
|
||||||
|
import HashtagBar from "../modals/HashtagBar";
|
||||||
|
|
||||||
const DEFAULT_DIFFICULTY = 0;
|
const DEFAULT_DIFFICULTY = 0;
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ const HashtagPage = () => {
|
|||||||
<main className="text-white mb-20">
|
<main className="text-white mb-20">
|
||||||
<div className="w-full px-4 sm:px-0 sm:max-w-xl mx-auto my-2">
|
<div className="w-full px-4 sm:px-0 sm:max-w-xl mx-auto my-2">
|
||||||
<NewNoteCard hashtag={id as string} />
|
<NewNoteCard hashtag={id as string} />
|
||||||
|
<HashtagBar />
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-1 max-w-xl mx-auto gap-1 px-4">
|
<div className="grid grid-cols-1 max-w-xl mx-auto gap-1 px-4">
|
||||||
{processedEvents.map((event) =>
|
{processedEvents.map((event) =>
|
||||||
|
@ -3,6 +3,7 @@ import { DEFAULT_DIFFICULTY } from "../../config";
|
|||||||
import PostCard from "../modals/PostCard";
|
import PostCard from "../modals/PostCard";
|
||||||
import { useState, useEffect, useMemo } from "react";
|
import { useState, useEffect, useMemo } from "react";
|
||||||
import useProcessedEvents from "../../hooks/processedEvents";
|
import useProcessedEvents from "../../hooks/processedEvents";
|
||||||
|
import HashtagBar from "../modals/HashtagBar";
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
const filterDifficulty = useMemo(() => {
|
const filterDifficulty = useMemo(() => {
|
||||||
@ -25,6 +26,7 @@ const Home = () => {
|
|||||||
<main className="text-white mb-20">
|
<main className="text-white mb-20">
|
||||||
<div className="w-full px-4 sm:px-0 sm:max-w-xl mx-auto my-2">
|
<div className="w-full px-4 sm:px-0 sm:max-w-xl mx-auto my-2">
|
||||||
<NewNoteCard />
|
<NewNoteCard />
|
||||||
|
<HashtagBar />
|
||||||
</div>
|
</div>
|
||||||
<div className={`grid grid-cols-1 max-w-xl mx-auto gap-1 ${isAnimating ? 'animate-pulse' : ''}`}>
|
<div className={`grid grid-cols-1 max-w-xl mx-auto gap-1 ${isAnimating ? 'animate-pulse' : ''}`}>
|
||||||
{processedEvents.map((event) => (
|
{processedEvents.map((event) => (
|
||||||
|
@ -56,7 +56,7 @@ const Thread = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<main className="bg-black text-white min-h-screen">
|
<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
|
{earlierEvents
|
||||||
.filter(event => event.kind === 1)
|
.filter(event => event.kind === 1)
|
||||||
.sort((a, b) => a.created_at - b.created_at).map((event, index) => (
|
.sort((a, b) => a.created_at - b.created_at).map((event, index) => (
|
||||||
|
Loading…
Reference in New Issue
Block a user