fix(wot): add exclude and fix wot dropdown
All checks were successful
Release to Staging / build_and_release (push) Successful in 48s

This commit is contained in:
enes 2024-11-20 12:27:41 +01:00
parent 54ab35e78c
commit 994382f39c
3 changed files with 13 additions and 5 deletions

View File

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

View File

@ -68,6 +68,12 @@ export const useFilteredMods = (
return isWoTNpub return isWoTNpub
? mods ? mods
: mods.filter((mod) => isInWoT(siteWot, siteWotLevel, mod.author)) : 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: case WOTFilterOptions.Site_Only:
return mods.filter((mod) => return mods.filter((mod) =>
isInWoT(siteWot, siteWotLevel, mod.author) isInWoT(siteWot, siteWotLevel, mod.author)

View File

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