Skip to content

Commit 4ba99e1

Browse files
fix lint frontend
1 parent 8c13b9d commit 4ba99e1

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

web-app/src/containers/LeftPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const LeftPanel = () => {
141141
return () => {
142142
window.removeEventListener('resize', handleResize)
143143
}
144-
}, [setLeftPanel])
144+
}, [setLeftPanel, open])
145145

146146
const currentPath = useRouterState({
147147
select: (state) => state.location.pathname,

web-app/src/containers/auth/UserProfileMenu.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import {
1313
DropdownMenuTrigger,
1414
} from '@/components/ui/dropdown-menu'
1515
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
16-
import { Button } from '@/components/ui/button'
17-
import { IconUser, IconLogout, IconChevronDown } from '@tabler/icons-react'
16+
import { IconUser, IconLogout } from '@tabler/icons-react'
1817
import { useTranslation } from '@/i18n/react-i18next-compat'
1918
import { useAuth } from '@/hooks/useAuth'
2019
import { toast } from 'sonner'

web-app/src/hooks/useThreadScrolling.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useMemo, useRef, useState } from 'react'
1+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
22
import { useAppState } from './useAppState'
33
import { useMessages } from './useMessages'
44
import { useShallow } from 'zustand/react/shallow'
@@ -25,16 +25,16 @@ export const useThreadScrolling = (
2525

2626
const showScrollToBottomBtn = !isAtBottom && hasScrollbar
2727

28-
const scrollToBottom = (smooth = false) => {
28+
const scrollToBottom = useCallback((smooth = false) => {
2929
if (scrollContainerRef.current) {
3030
scrollContainerRef.current.scrollTo({
3131
top: scrollContainerRef.current.scrollHeight,
3232
...(smooth ? { behavior: 'smooth' } : {}),
3333
})
3434
}
35-
}
35+
}, [])
3636

37-
const handleScroll = (e: Event) => {
37+
const handleScroll = useCallback((e: Event) => {
3838
const target = e.target as HTMLDivElement
3939
const { scrollTop, scrollHeight, clientHeight } = target
4040
// Use a small tolerance to better detect when we're at the bottom
@@ -53,17 +53,18 @@ export const useThreadScrolling = (
5353
setIsAtBottom(isBottom)
5454
setHasScrollbar(hasScroll)
5555
lastScrollTopRef.current = scrollTop
56-
}
56+
}, [streamingContent])
5757

5858
useEffect(() => {
59-
if (scrollContainerRef.current) {
60-
scrollContainerRef.current.addEventListener('scroll', handleScroll)
59+
const scrollContainer = scrollContainerRef.current
60+
if (scrollContainer) {
61+
scrollContainer.addEventListener('scroll', handleScroll)
6162
return () =>
62-
scrollContainerRef.current?.removeEventListener('scroll', handleScroll)
63+
scrollContainer.removeEventListener('scroll', handleScroll)
6364
}
64-
}, [scrollContainerRef])
65+
}, [handleScroll])
6566

66-
const checkScrollState = () => {
67+
const checkScrollState = useCallback(() => {
6768
const scrollContainer = scrollContainerRef.current
6869
if (!scrollContainer) return
6970

@@ -73,7 +74,7 @@ export const useThreadScrolling = (
7374

7475
setIsAtBottom(isBottom)
7576
setHasScrollbar(hasScroll)
76-
}
77+
}, [])
7778

7879
// Single useEffect for all auto-scrolling logic
7980
useEffect(() => {
@@ -120,7 +121,7 @@ export const useThreadScrolling = (
120121
const interval = setInterval(checkScrollState, 100)
121122
return () => clearInterval(interval)
122123
}
123-
}, [streamingContent])
124+
}, [streamingContent, checkScrollState])
124125

125126
// Auto-scroll to bottom when component mounts or thread content changes
126127
useEffect(() => {
@@ -138,7 +139,7 @@ export const useThreadScrolling = (
138139
checkScrollState()
139140
return
140141
}
141-
}, [])
142+
}, [checkScrollState, scrollToBottom])
142143

143144
const handleDOMScroll = (e: Event) => {
144145
const target = e.target as HTMLDivElement
@@ -182,7 +183,7 @@ export const useThreadScrolling = (
182183
userIntendedPositionRef.current = null
183184
wasStreamingRef.current = false
184185
checkScrollState()
185-
}, [threadId])
186+
}, [threadId, checkScrollState, scrollToBottom])
186187

187188
return useMemo(
188189
() => ({ showScrollToBottomBtn, scrollToBottom, setIsUserScrolling }),

web-app/src/providers/AuthProvider.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Initializes the auth service and sets up event listeners
44
*/
55

6-
import { useEffect, useState, ReactNode } from 'react'
6+
import { useCallback, useEffect, useState, ReactNode } from 'react'
77
import { PlatformFeature } from '@/lib/platform/types'
88
import { PlatformFeatures } from '@/lib/platform/const'
99
import { initializeAuthStore, getAuthStore } from '@/hooks/useAuth'
@@ -28,7 +28,7 @@ export function AuthProvider({ children }: AuthProviderProps) {
2828
PlatformFeatures[PlatformFeature.AUTHENTICATION]
2929

3030
// Fetch user data when user logs in
31-
const fetchUserData = async () => {
31+
const fetchUserData = useCallback(async () => {
3232
try {
3333
const { setThreads } = useThreads.getState()
3434
const { setMessages } = useMessages.getState()
@@ -47,10 +47,10 @@ export function AuthProvider({ children }: AuthProviderProps) {
4747
} catch (error) {
4848
console.error('Failed to fetch user data:', error)
4949
}
50-
}
50+
}, [serviceHub])
5151

5252
// Reset all app data when user logs out
53-
const resetAppData = () => {
53+
const resetAppData = useCallback(() => {
5454
// Clear all threads (including favorites)
5555
const { clearAllThreads, setCurrentThreadId } = useThreads.getState()
5656
clearAllThreads()
@@ -70,7 +70,7 @@ export function AuthProvider({ children }: AuthProviderProps) {
7070

7171
// Navigate back to home to ensure clean state
7272
navigate({ to: '/', replace: true })
73-
}
73+
}, [navigate])
7474

7575
useEffect(() => {
7676
if (!isAuthenticationEnabled) {
@@ -139,7 +139,7 @@ export function AuthProvider({ children }: AuthProviderProps) {
139139
return () => {
140140
cleanupAuthListener()
141141
}
142-
}, [isAuthenticationEnabled, isReady])
142+
}, [isAuthenticationEnabled, isReady, fetchUserData, resetAppData])
143143

144144
return <>{isReady && children}</>
145145
}

0 commit comments

Comments
 (0)