WoT implemented, plus other fixes #160
@ -54,18 +54,29 @@ export const useFilteredMods = (
|
||||
}
|
||||
|
||||
const wotFilter = (mods: ModDetails[]) => {
|
||||
// Determine the filtering logic based on the WOT filter option
|
||||
// Determine the filtering logic based on the WOT filter option and user state
|
||||
// when user is not logged in use Site_Only
|
||||
if (!userState.auth) {
|
||||
return mods.filter((mod) => isInWoT(siteWot, siteWotLevel, mod.author))
|
||||
}
|
||||
// when user is logged, allow other filter selections
|
||||
const isWoTNpub =
|
||||
userState.user?.npub === import.meta.env.VITE_SITE_WOT_NPUB
|
||||
switch (filterOptions.wot) {
|
||||
case WOTFilterOptions.None:
|
||||
return mods
|
||||
// Only admins can choose None, use siteWoT for others
|
||||
return isWoTNpub
|
||||
? mods
|
||||
: mods.filter((mod) => isInWoT(siteWot, siteWotLevel, mod.author))
|
||||
case WOTFilterOptions.Site_Only:
|
||||
return mods.filter((mod) =>
|
||||
isInWoT(siteWot, siteWotLevel, mod.author)
|
||||
)
|
||||
case WOTFilterOptions.Mine_Only:
|
||||
return mods.filter((mod) =>
|
||||
isInWoT(userWot, userWotLevel, mod.author)
|
||||
)
|
||||
// Only admins can choose Mine_Only, use siteWoT for others
|
||||
return isWoTNpub
|
||||
? mods.filter((mod) => isInWoT(userWot, userWotLevel, mod.author))
|
||||
: mods.filter((mod) => isInWoT(siteWot, siteWotLevel, mod.author))
|
||||
case WOTFilterOptions.Site_And_Mine:
|
||||
return mods.filter(
|
||||
(mod) =>
|
||||
|
Loading…
Reference in New Issue
Block a user