WoT implemented, plus other fixes #160

Merged
freakoverse merged 36 commits from staging into master 2024-11-20 16:39:08 +00:00
3 changed files with 13 additions and 5 deletions
Showing only changes of commit 994382f39c - Show all commits

View File

@ -125,18 +125,19 @@ export const ModFilter = React.memo(
// when logged in user not admin
if (
item === WOTFilterOptions.None ||
item === WOTFilterOptions.Mine_Only
item === WOTFilterOptions.Mine_Only ||
item === WOTFilterOptions.Exclude
) {
const isAdmin =
const isWoTNpub =
userState.user?.npub ===
import.meta.env.VITE_REPORTING_NPUB
import.meta.env.VITE_SITE_WOT_NPUB
const isOwnProfile =
author &&
userState.auth &&
userState.user?.pubkey === author
if (!(isAdmin || isOwnProfile)) return null
if (!(isWoTNpub || isOwnProfile)) return null
}
return (

View File

@ -68,6 +68,12 @@ export const useFilteredMods = (
return isWoTNpub
? mods
: mods.filter((mod) => isInWoT(siteWot, siteWotLevel, mod.author))
case WOTFilterOptions.Exclude:
// Only admins can choose Exlude, use siteWot for others
// Exlude returns the mods not in the site's WoT
return isWoTNpub
? mods.filter((mod) => !isInWoT(siteWot, siteWotLevel, mod.author))
: mods.filter((mod) => isInWoT(siteWot, siteWotLevel, mod.author))
case WOTFilterOptions.Site_Only:
return mods.filter((mod) =>
isInWoT(siteWot, siteWotLevel, mod.author)

View File

@ -21,7 +21,8 @@ export enum WOTFilterOptions {
Site_And_Mine = 'Site & Mine',
Site_Only = 'Site Only',
Mine_Only = 'Mine Only',
None = 'None'
None = 'None',
Exclude = 'Exclude'
}
export interface FilterOptions {