diff --git a/src/components/PostWarning.tsx b/src/components/PostWarning.tsx
new file mode 100644
index 0000000..f476c67
--- /dev/null
+++ b/src/components/PostWarning.tsx
@@ -0,0 +1,22 @@
+interface PostWarningsProps {
+ type: 'user' | 'admin'
+}
+
+export const PostWarnings = ({ type }: PostWarningsProps) => (
+
+
+ {type === 'admin' ? (
+ <>
+ Warning: This post has been blocked/hidden by the site for one of the
+ following reasons:
+
+ Malware, Not a Mod, Illegal, Spam, Verified Report of Unauthorized
+ Repost.
+
+ >
+ ) : (
+ <>Notice: You have blocked this post>
+ )}
+
+
+)
diff --git a/src/layout/header.tsx b/src/layout/header.tsx
index 1871374..8b6b454 100644
--- a/src/layout/header.tsx
+++ b/src/layout/header.tsx
@@ -3,7 +3,7 @@ import {
launch as launchNostrLoginDialog
} from 'nostr-login'
import React, { useEffect, useState } from 'react'
-import { Link } from 'react-router-dom'
+import { Link, useRevalidator } from 'react-router-dom'
import { Banner } from '../components/Banner'
import { ZapPopUp } from '../components/Zap'
import {
@@ -27,7 +27,7 @@ export const Header = () => {
const dispatch = useAppDispatch()
const { findMetadata } = useNDKContext()
const userState = useAppSelector((state) => state.user)
-
+ const revalidator = useRevalidator()
// Track nostr-login extension modal open state
const [isOpen, setIsOpen] = useState(false)
const handleOpen = () => setIsOpen(true)
@@ -75,8 +75,12 @@ export const Header = () => {
}
})
}
+
+ // React router - revalidate loader states on auth changes
+ revalidator.revalidate()
}
})
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [dispatch, findMetadata])
const handleLogin = () => {
@@ -447,7 +451,9 @@ const RegisterButtonWithDialog = () => {
color: '#ffffffbf'
}}
>
- Warning: Make sure you backup your private key somewhere safe. If you lose it or it gets leaked, we actually can't help you.
+ Warning: Make sure you backup your private key
+ somewhere safe. If you lose it or it gets leaked, we
+ actually can't help you.
{
- const { blog, latest, isAddedToNSFW, isBlocked } =
+ const { blog, latest, isAddedToNSFW, isBlocked, postWarning } =
useLoaderData() as BlogPageLoaderResult
const userState = useAppSelector((state) => state.user)
const isAdmin =
@@ -84,6 +85,7 @@ export const BlogPage = () => {
<>
+ {postWarning &&
}
{
- const { mod } = useLoaderData() as ModPageLoaderResult
+ const { mod, postWarning } = useLoaderData() as ModPageLoaderResult
// We can get author right away from naddr, no need to wait for mod data
const { naddr } = useParams()
@@ -98,6 +99,7 @@ export const ModPage = () => {
<>
+ {postWarning &&
}
{
Mod Download
+ {postWarning &&
}
{mod.downloadUrls.length > 0 && (
diff --git a/src/pages/mod/loader.ts b/src/pages/mod/loader.ts
index e490e65..afc7fa9 100644
--- a/src/pages/mod/loader.ts
+++ b/src/pages/mod/loader.ts
@@ -50,6 +50,7 @@ export const modRouteLoader =
const userState = store.getState().user
const loggedInUserPubkey =
(userState?.user?.pubkey as string | undefined) || getFallbackPubkey()
+ const isAdmin = userState.user?.npub === import.meta.env.VITE_REPORTING_NPUB
// Check if editing and the user is the original author
// Redirect if NOT
@@ -146,10 +147,27 @@ export const modRouteLoader =
if (muteLists.status === 'fulfilled' && muteLists.value) {
if (muteLists && muteLists.value) {
if (result.mod && result.mod.aTag) {
+ // Show user or admin post warning if any mute list includes either post or author
+ if (
+ muteLists.value.user.replaceableEvents.includes(
+ result.mod.aTag
+ ) ||
+ muteLists.value.user.authors.includes(result.mod.author)
+ ) {
+ result.postWarning = 'user'
+ }
+
if (
muteLists.value.admin.replaceableEvents.includes(
result.mod.aTag
) ||
+ muteLists.value.admin.authors.includes(result.mod.author)
+ ) {
+ result.postWarning = 'admin'
+ }
+
+ // Check if user has blocked this profile
+ if (
muteLists.value.user.replaceableEvents.includes(result.mod.aTag)
) {
result.isBlocked = true
@@ -157,8 +175,6 @@ export const modRouteLoader =
}
// Moderate the latest
- const isAdmin =
- userState.user?.npub === import.meta.env.VITE_REPORTING_NPUB
const isOwner =
userState.user?.pubkey && userState.user.pubkey === pubkey
const isUnmoderatedFully =
diff --git a/src/types/blog.ts b/src/types/blog.ts
index 813c76c..7e7fc18 100644
--- a/src/types/blog.ts
+++ b/src/types/blog.ts
@@ -39,6 +39,7 @@ export interface BlogPageLoaderResult {
latest: Partial[]
isAddedToNSFW: boolean
isBlocked: boolean
+ postWarning?: 'user' | 'admin'
}
export interface BlogsFilterOptions {
diff --git a/src/types/mod.ts b/src/types/mod.ts
index 1b4ae53..a62fe5b 100644
--- a/src/types/mod.ts
+++ b/src/types/mod.ts
@@ -66,6 +66,7 @@ export interface ModPageLoaderResult {
isAddedToNSFW: boolean
isBlocked: boolean
isRepost: boolean
+ postWarning?: 'user' | 'admin'
}
export type SubmitModActionResult =