WoT implemented, plus other fixes #160
@ -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 (
|
||||||
|
@ -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)
|
||||||
|
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user