@@ -32,7 +32,7 @@ export default function ActivityPage() {
3232 const [ hasMore , setHasMore ] = useState ( true ) ;
3333
3434 const fetchActivity = useCallback (
35- async ( pageNum : number , tab : string , append : boolean = false ) => {
35+ async ( pageNum : number , tab : string , append : boolean = false , signal ?: AbortSignal ) => {
3636 if ( ! session ?. publicKey ) return ;
3737 setLoading ( true ) ;
3838
@@ -43,7 +43,7 @@ export default function ActivityPage() {
4343 `${ API_BASE_URL } /v1/events?address=${ encodeURIComponent ( session . publicKey ) } ` +
4444 `&page=${ pageNum } &limit=${ PAGE_SIZE } ${ typeQuery } ` ;
4545
46- const response = await fetch ( url ) ;
46+ const response = await fetch ( url , { signal } ) ;
4747 if ( ! response . ok ) {
4848 throw new Error ( `Failed to fetch activity (${ response . status } )` ) ;
4949 }
@@ -62,6 +62,7 @@ export default function ActivityPage() {
6262 setHasMore ( next . length === PAGE_SIZE ) ;
6363 }
6464 } catch ( error ) {
65+ if ( error instanceof DOMException && error . name === "AbortError" ) return ;
6566 console . error ( "Failed to fetch activity:" , error ) ;
6667 if ( ! append ) setEvents ( [ ] ) ;
6768 setHasMore ( false ) ;
@@ -73,10 +74,11 @@ export default function ActivityPage() {
7374 ) ;
7475
7576 useEffect ( ( ) => {
76- if ( status === "connected" ) {
77- setPage ( 1 ) ;
78- fetchActivity ( 1 , activeTab , false ) ;
79- }
77+ if ( status !== "connected" ) return ;
78+ const controller = new AbortController ( ) ;
79+ setPage ( 1 ) ;
80+ fetchActivity ( 1 , activeTab , false , controller . signal ) ;
81+ return ( ) => controller . abort ( ) ;
8082 } , [ activeTab , status , fetchActivity ] ) ;
8183
8284 const loadMore = ( ) => {
0 commit comments