mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-11 22:51:05 +00:00
fix: fetch chat history when opening recent conversations sheet (#919)
This commit is contained in:
parent
b9f3bcad93
commit
82ff92b560
1 changed files with 12 additions and 7 deletions
|
|
@ -399,6 +399,12 @@ export function ChatSidebar({
|
|||
}
|
||||
}, [selectedProject])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isHistoryOpen) return
|
||||
fetchThreads()
|
||||
analytics.chatHistoryViewed?.()
|
||||
}, [isHistoryOpen, fetchThreads])
|
||||
|
||||
const loadThread = useCallback(
|
||||
async (id: string) => {
|
||||
try {
|
||||
|
|
@ -441,12 +447,14 @@ export function ChatSidebar({
|
|||
|
||||
// Auto-restore thread from URL on mount (e.g. reload or direct link)
|
||||
const didAutoLoadRef = useRef(false)
|
||||
const initialThreadIdRef = useRef(threadId)
|
||||
useEffect(() => {
|
||||
if (didAutoLoadRef.current) return
|
||||
if (!threadId) return
|
||||
const initialThreadId = initialThreadIdRef.current
|
||||
if (!initialThreadId) return
|
||||
didAutoLoadRef.current = true
|
||||
loadThread(threadId)
|
||||
}, [threadId, loadThread])
|
||||
loadThread(initialThreadId)
|
||||
}, [loadThread])
|
||||
|
||||
const deleteThread = useCallback(
|
||||
async (threadId: string) => {
|
||||
|
|
@ -596,10 +604,7 @@ export function ChatSidebar({
|
|||
open={isHistoryOpen}
|
||||
onOpenChange={(open) => {
|
||||
setIsHistoryOpen(open)
|
||||
if (open) {
|
||||
fetchThreads()
|
||||
analytics.chatHistoryViewed?.()
|
||||
} else {
|
||||
if (!open) {
|
||||
setConfirmingDeleteId(null)
|
||||
}
|
||||
}}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue