Create codemod for addressing ESLint warnings (#10032)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React from 'react'
|
||||
import {useCallback, useEffect, useMemo, useRef, useState} from 'react'
|
||||
import {type AppBskyActorDefs as ActorDefs} from '@atproto/api'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
@@ -47,7 +47,7 @@ export function ProfileFollowers({name}: {name: string}) {
|
||||
const initialNumToRender = useInitialNumToRender()
|
||||
const {currentAccount} = useSession()
|
||||
|
||||
const [isPTRing, setIsPTRing] = React.useState(false)
|
||||
const [isPTRing, setIsPTRing] = useState(false)
|
||||
const {
|
||||
data: resolvedDid,
|
||||
isLoading: isDidLoading,
|
||||
@@ -66,7 +66,7 @@ export function ProfileFollowers({name}: {name: string}) {
|
||||
const isError = !!resolveError || !!error
|
||||
const isMe = resolvedDid === currentAccount?.did
|
||||
|
||||
const followers = React.useMemo(() => {
|
||||
const followers = useMemo(() => {
|
||||
if (data?.pages) {
|
||||
return data.pages.flatMap(page => page.followers)
|
||||
}
|
||||
@@ -74,11 +74,11 @@ export function ProfileFollowers({name}: {name: string}) {
|
||||
}, [data])
|
||||
|
||||
// Track pagination events - fire for page 3+ (pages 1-2 may auto-load)
|
||||
const paginationTrackingRef = React.useRef<{
|
||||
const paginationTrackingRef = useRef<{
|
||||
did: string | undefined
|
||||
page: number
|
||||
}>({did: undefined, page: 0})
|
||||
React.useEffect(() => {
|
||||
useEffect(() => {
|
||||
const currentPageCount = data?.pages?.length || 0
|
||||
// Reset tracking when profile changes
|
||||
if (paginationTrackingRef.current.did !== resolvedDid) {
|
||||
@@ -99,7 +99,7 @@ export function ProfileFollowers({name}: {name: string}) {
|
||||
paginationTrackingRef.current.page = currentPageCount
|
||||
}, [ax, data?.pages?.length, resolvedDid, followers.length])
|
||||
|
||||
const onRefresh = React.useCallback(async () => {
|
||||
const onRefresh = useCallback(async () => {
|
||||
setIsPTRing(true)
|
||||
try {
|
||||
await refetch()
|
||||
@@ -109,7 +109,7 @@ export function ProfileFollowers({name}: {name: string}) {
|
||||
setIsPTRing(false)
|
||||
}, [refetch, setIsPTRing])
|
||||
|
||||
const onEndReached = React.useCallback(async () => {
|
||||
const onEndReached = useCallback(async () => {
|
||||
if (isFetchingNextPage || !hasNextPage || !!error) return
|
||||
try {
|
||||
await fetchNextPage()
|
||||
@@ -118,14 +118,14 @@ export function ProfileFollowers({name}: {name: string}) {
|
||||
}
|
||||
}, [isFetchingNextPage, hasNextPage, error, fetchNextPage])
|
||||
|
||||
const renderItemWithContext = React.useCallback(
|
||||
const renderItemWithContext = useCallback(
|
||||
({item, index}: {item: ActorDefs.ProfileView; index: number}) =>
|
||||
renderItem({item, index, contextProfileDid: resolvedDid}),
|
||||
[resolvedDid],
|
||||
)
|
||||
|
||||
// track pageview
|
||||
React.useEffect(() => {
|
||||
useEffect(() => {
|
||||
if (resolvedDid) {
|
||||
ax.metric('profile:followers:view', {
|
||||
contextProfileDid: resolvedDid,
|
||||
@@ -135,11 +135,11 @@ export function ProfileFollowers({name}: {name: string}) {
|
||||
}, [ax, resolvedDid, isMe])
|
||||
|
||||
// track seen items
|
||||
const seenItemsRef = React.useRef<Set<string>>(new Set())
|
||||
React.useEffect(() => {
|
||||
const seenItemsRef = useRef<Set<string>>(new Set())
|
||||
useEffect(() => {
|
||||
seenItemsRef.current.clear()
|
||||
}, [resolvedDid])
|
||||
const onItemSeen = React.useCallback(
|
||||
const onItemSeen = useCallback(
|
||||
(item: ActorDefs.ProfileView) => {
|
||||
if (seenItemsRef.current.has(item.did)) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user