fix(mod): loading mod edge case
All checks were successful
Release to Staging / build_and_release (push) Successful in 1m2s

Close #175 - Add timeout to requests and try again button
This commit is contained in:
enes 2025-01-01 16:16:39 +01:00
parent c6c2013f1e
commit e15307be3b
2 changed files with 20 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import { Link, useRouteError } from 'react-router-dom' import { Link, useLocation, useRouteError } from 'react-router-dom'
import { appRoutes } from 'routes' import { appRoutes } from 'routes'
interface NotFoundPageProps { interface NotFoundPageProps {
@ -12,6 +12,8 @@ export const NotFoundPage = ({
}: Partial<NotFoundPageProps>) => { }: Partial<NotFoundPageProps>) => {
const error = useRouteError() as Partial<NotFoundPageProps> const error = useRouteError() as Partial<NotFoundPageProps>
const location = useLocation()
return ( return (
<div className='InnerBodyMain'> <div className='InnerBodyMain'>
<div className='ContainerMain'> <div className='ContainerMain'>
@ -23,7 +25,19 @@ export const NotFoundPage = ({
<div> <div>
<p>{error?.message || message}</p> <p>{error?.message || message}</p>
</div> </div>
<div className='IBMSMAction'> <div
className='IBMSMAction'
style={{
gap: '10px'
}}
>
<Link
to={location.pathname}
className='btn btnMain IBMSMActionBtn'
type='button'
>
Try again
</Link>
<Link <Link
to={appRoutes.home} to={appRoutes.home}
className='btn btnMain IBMSMActionBtn' className='btn btnMain IBMSMActionBtn'

View File

@ -20,7 +20,8 @@ import {
getLocalStorageItem, getLocalStorageItem,
getReportingSet, getReportingSet,
log, log,
LogType LogType,
timeout
} from 'utils' } from 'utils'
export const modRouteLoader = export const modRouteLoader =
@ -84,8 +85,8 @@ export const modRouteLoader =
// Parallel fetch mod event, latest events, mute, nsfw, repost lists // Parallel fetch mod event, latest events, mute, nsfw, repost lists
const settled = await Promise.allSettled([ const settled = await Promise.allSettled([
ndkContext.fetchEvent(modFilter), Promise.race([ndkContext.fetchEvent(modFilter), timeout(2000)]),
ndkContext.fetchEvents(latestFilter), Promise.race([ndkContext.fetchEvents(latestFilter), timeout(2000)]),
ndkContext.getMuteLists(loggedInUserPubkey), // Pass pubkey for logged-in users ndkContext.getMuteLists(loggedInUserPubkey), // Pass pubkey for logged-in users
getReportingSet(CurationSetIdentifiers.NSFW, ndkContext), getReportingSet(CurationSetIdentifiers.NSFW, ndkContext),
getReportingSet(CurationSetIdentifiers.Repost, ndkContext) getReportingSet(CurationSetIdentifiers.Repost, ndkContext)