diff --git a/src/components/Filters/ModsFilter.tsx b/src/components/Filters/ModsFilter.tsx index 44f182d..722c804 100644 --- a/src/components/Filters/ModsFilter.tsx +++ b/src/components/Filters/ModsFilter.tsx @@ -48,10 +48,14 @@ export const ModFilter = React.memo( {/* moderation filter options */} {Object.values(ModeratedFilter).map((item, index) => { - if (item === ModeratedFilter.Unmoderated_Fully) { - const isAdmin = - userState.user?.npub === import.meta.env.VITE_REPORTING_NPUB + const isAdmin = + userState.user?.npub === import.meta.env.VITE_REPORTING_NPUB + if (item === ModeratedFilter.Only_Blocked && !isAdmin) { + return null + } + + if (item === ModeratedFilter.Unmoderated_Fully) { const isOwnProfile = author && userState.auth && userState.user?.pubkey === author diff --git a/src/hooks/useFilteredMods.ts b/src/hooks/useFilteredMods.ts index ef7c249..4779869 100644 --- a/src/hooks/useFilteredMods.ts +++ b/src/hooks/useFilteredMods.ts @@ -128,10 +128,19 @@ export const useFilteredMods = ( npubToHex(userState.user.npub as string) === author const isUnmoderatedFully = filterOptions.moderated === ModeratedFilter.Unmoderated_Fully + const isOnlyBlocked = + filterOptions.moderated === ModeratedFilter.Only_Blocked - // Only apply filtering if the user is not an admin or the admin has not selected "Unmoderated Fully" - // Allow "Unmoderated Fully" when author visits own profile - if (!((isAdmin || isOwner) && isUnmoderatedFully)) { + if (isOnlyBlocked && isAdmin) { + filtered = filtered.filter( + (mod) => + muteLists.admin.authors.includes(mod.author) || + muteLists.admin.replaceableEvents.includes(mod.aTag) + ) + } else if (isUnmoderatedFully && (isAdmin || isOwner)) { + // Only apply filtering if the user is not an admin or the admin has not selected "Unmoderated Fully" + // Allow "Unmoderated Fully" when author visits own profile + } else { filtered = filtered.filter( (mod) => !muteLists.admin.authors.includes(mod.author) && diff --git a/src/pages/blog/loader.ts b/src/pages/blog/loader.ts index b5657e1..bce006b 100644 --- a/src/pages/blog/loader.ts +++ b/src/pages/blog/loader.ts @@ -119,7 +119,7 @@ export const blogRouteLoader = throw new Error('We are unable to find the blog on the relays') } - // Check the lateast blog events + // Check the latest blog events const fetchEventsResult = settled[1] if (fetchEventsResult.status === 'fulfilled' && fetchEventsResult.value) { // Extract the blog card details from the events diff --git a/src/pages/mod/loader.ts b/src/pages/mod/loader.ts index afc7fa9..a3c6fec 100644 --- a/src/pages/mod/loader.ts +++ b/src/pages/mod/loader.ts @@ -129,7 +129,7 @@ export const modRouteLoader = throw new Error('We are unable to find the mod on the relays') } - // Check the lateast blog events + // Check the latest blog events const fetchEventsResult = settled[1] if (fetchEventsResult.status === 'fulfilled' && fetchEventsResult.value) { // Extract the blog card details from the events diff --git a/src/pages/profile/index.tsx b/src/pages/profile/index.tsx index 2675fa4..5aacbbc 100644 --- a/src/pages/profile/index.tsx +++ b/src/pages/profile/index.tsx @@ -767,6 +767,8 @@ const ProfileTabBlogs = () => { userState.user?.pubkey && userState.user.pubkey === profilePubkey const isUnmoderatedFully = filterOptions.moderated === ModeratedFilter.Unmoderated_Fully + const isOnlyBlocked = + filterOptions.moderated === ModeratedFilter.Only_Blocked // Add nsfw tag to blogs included in nsfwList if (filterOptions.nsfw !== NSFWFilter.Hide_NSFW) { @@ -782,9 +784,16 @@ const ProfileTabBlogs = () => { (b) => !(b.nsfw && filterOptions.nsfw === NSFWFilter.Hide_NSFW) ) - // Only apply filtering if the user is not an admin or the admin has not selected "Unmoderated Fully" - // Allow "Unmoderated Fully" when author visits own profile - if (!((isAdmin || isOwner) && isUnmoderatedFully)) { + if (isOnlyBlocked && isAdmin) { + _blogs = _blogs.filter( + (b) => + muteLists.admin.authors.includes(b.author!) || + muteLists.admin.replaceableEvents.includes(b.aTag!) + ) + } else if (isUnmoderatedFully && (isAdmin || isOwner)) { + // Only apply filtering if the user is not an admin or the admin has not selected "Unmoderated Fully" + // Allow "Unmoderated Fully" when author visits own profile + } else { _blogs = _blogs.filter( (b) => !muteLists.admin.authors.includes(b.author!) && diff --git a/src/pages/search.tsx b/src/pages/search.tsx index 68ff768..b294ce9 100644 --- a/src/pages/search.tsx +++ b/src/pages/search.tsx @@ -174,12 +174,15 @@ const Filters = React.memo(() => {
{Object.values(ModeratedFilter).map((item, index) => { - if (item === ModeratedFilter.Unmoderated_Fully) { - const isAdmin = - userState.user?.npub === - import.meta.env.VITE_REPORTING_NPUB + const isAdmin = + userState.user?.npub === import.meta.env.VITE_REPORTING_NPUB - if (!isAdmin) return null + if (item === ModeratedFilter.Only_Blocked && !isAdmin) { + return null + } + + if (item === ModeratedFilter.Unmoderated_Fully && !isAdmin) { + return null } return ( @@ -439,9 +442,16 @@ const UsersResult = ({ const isAdmin = userState.user?.npub === import.meta.env.VITE_REPORTING_NPUB const isUnmoderatedFully = moderationFilter === ModeratedFilter.Unmoderated_Fully + const isOnlyBlocked = moderationFilter === ModeratedFilter.Only_Blocked - // Only apply filtering if the user is not an admin or the admin has not selected "Unmoderated Fully" - if (!(isAdmin && isUnmoderatedFully)) { + if (isOnlyBlocked && isAdmin) { + filtered = filtered.filter((profile) => + muteLists.admin.authors.includes(profile.pubkey as string) + ) + } else if (isUnmoderatedFully && isAdmin) { + // Only apply filtering if the user is not an admin + // or the admin has not selected "Unmoderated Fully" + } else { filtered = filtered.filter( (profile) => !muteLists.admin.authors.includes(profile.pubkey as string) ) diff --git a/src/types/modsFilter.ts b/src/types/modsFilter.ts index 6310f1d..fa5c399 100644 --- a/src/types/modsFilter.ts +++ b/src/types/modsFilter.ts @@ -14,7 +14,8 @@ export enum NSFWFilter { export enum ModeratedFilter { Moderated = 'Moderated', Unmoderated = 'Unmoderated', - Unmoderated_Fully = 'Unmoderated Fully' + Unmoderated_Fully = 'Unmoderated Fully', + Only_Blocked = 'Only Moderated' } export enum WOTFilterOptions {