Skip to content

Commit 25fd38e

Browse files
committed
refactor: update project listing depending on the dev mode
1 parent ceff204 commit 25fd38e

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/components/notifications/AppExplorer/AppCard/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useNavigate } from 'react-router-dom'
66
import SpannerSVG from '@/assets/Spanner.svg'
77
import Badge from '@/components/general/Badge'
88
import Text from '@/components/general/Text'
9+
import SettingsContext from '@/contexts/SettingsContext/context'
910
import W3iContext from '@/contexts/W3iContext/context'
1011
import { logError } from '@/utils/error'
1112
import { showErrorMessageToast, showSuccessMessageToast } from '@/utils/toasts'
@@ -37,6 +38,7 @@ const AppCard: React.FC<AppCardProps> = ({
3738
const nav = useNavigate()
3839
const ref = useRef<HTMLDivElement>(null)
3940
const { notifyClientProxy, userPubkey } = useContext(W3iContext)
41+
const { isDevModeEnabled } = useContext(SettingsContext)
4042
const { activeSubscriptions } = useContext(W3iContext)
4143

4244
const host = new URL(url).host
@@ -112,7 +114,7 @@ const AppCard: React.FC<AppCardProps> = ({
112114
<div className="AppCard__header">
113115
<div className="AppCard__header__logo">
114116
<img src={logo || '/fallback.svg'} alt={`${name} logo`} />
115-
{!isVerified && !isComingSoon ? (
117+
{isDevModeEnabled && !isVerified && !isComingSoon ? (
116118
<img src={SpannerSVG} className="AppCard__header__logo__dev-icon" alt="Dev mode icon" />
117119
) : null}
118120
</div>
@@ -132,7 +134,7 @@ const AppCard: React.FC<AppCardProps> = ({
132134
<div className="AppCard__body">
133135
<div className="AppCard__body__title">
134136
<Text variant="large-600">{name}</Text>
135-
{!isVerified && !isComingSoon ? <Badge>DEV</Badge> : null}
137+
{isDevModeEnabled && !isVerified && !isComingSoon ? <Badge>DEV</Badge> : null}
136138
</div>
137139
<Text className="AppCard__body__subtitle" variant="tiny-500">
138140
{host}

src/utils/hooks/useNotifyProjects.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ import { logError } from '../error'
1010
const useNotifyProjects = () => {
1111
const [loading, setLoading] = useState(false)
1212
const [projects, setProjects] = useState<INotifyApp[]>([])
13-
const { filterAppDomain } = useContext(SettingsContext)
13+
const { filterAppDomain, isDevModeEnabled } = useContext(SettingsContext)
1414

1515
useEffect(() => {
1616
const fetchNotifyProjects = async () => {
1717
setLoading(true)
1818

1919
try {
20-
const { data: featuredProjects } = await fetchFeaturedProjects<INotifyProject[]>()
20+
const { data: featuredProjects } = await fetchFeaturedProjects<INotifyProject[]>({
21+
isDevModeEnabled
22+
})
2123
const { data: domainProject } = await fetchDomainProjects<INotifyProject>(filterAppDomain)
2224

2325
const allProjects: INotifyProjectWithComingSoon[] = featuredProjects.map(item => ({
@@ -61,7 +63,7 @@ const useNotifyProjects = () => {
6163
}
6264

6365
fetchNotifyProjects()
64-
}, [setProjects, filterAppDomain])
66+
}, [isDevModeEnabled, setProjects, filterAppDomain])
6567

6668
return { projects, loading }
6769
}

src/utils/projects.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ import { EXPLORER_API_BASE_URL, EXPLORER_ENDPOINTS } from '@/utils/constants'
22

33
const projectId: string = import.meta.env.VITE_PROJECT_ID
44

5-
export async function fetchFeaturedProjects<T>() {
5+
type FetchFeaturedProjectsProps = {
6+
isDevModeEnabled: boolean
7+
}
8+
9+
export async function fetchFeaturedProjects<T>({ isDevModeEnabled }: FetchFeaturedProjectsProps) {
610
const explorerUrlFeatured = new URL(EXPLORER_ENDPOINTS.projects, EXPLORER_API_BASE_URL)
711

812
explorerUrlFeatured.searchParams.set('projectId', projectId)
913
explorerUrlFeatured.searchParams.set('isVerified', 'true')
10-
explorerUrlFeatured.searchParams.set('isFeatured', 'true')
14+
if (!isDevModeEnabled) {
15+
explorerUrlFeatured.searchParams.set('isFeatured', 'true')
16+
}
1117

1218
try {
1319
const discoverProjectsData = await fetch(explorerUrlFeatured).then(async res => res.json())

0 commit comments

Comments
 (0)