chore: clean up repo for public release
- Remove BMAD framework, IDE configs, dev screenshots, test files, internal docs, and backup files - Rename keep-notes/ to memento-note/ - Update all references from keep-notes to memento-note - Add Apache 2.0 license with Commons Clause (non-commercial restriction) - Add clean .gitignore and .env.docker.example
This commit is contained in:
44
memento-note/hooks/use-connections-compare.ts
Normal file
44
memento-note/hooks/use-connections-compare.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
'use client'
|
||||
|
||||
import { useState, useEffect } from 'react'
|
||||
import { getNoteById } from '@/app/actions/notes'
|
||||
import { Note } from '@/lib/types'
|
||||
|
||||
export function useConnectionsCompare(noteIds: string[] | null) {
|
||||
const [notes, setNotes] = useState<Note[]>([])
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
// Early return if no noteIds or empty array
|
||||
if (!noteIds || noteIds.length === 0) {
|
||||
setNotes([])
|
||||
return
|
||||
}
|
||||
|
||||
const fetchNotes = async () => {
|
||||
setIsLoading(true)
|
||||
setError(null)
|
||||
|
||||
try {
|
||||
const fetchedNotes = await Promise.all(
|
||||
noteIds.map(id => getNoteById(id))
|
||||
)
|
||||
|
||||
// Filter out null/undefined notes
|
||||
const validNotes = fetchedNotes.filter((note): note is Note => note !== null && note !== undefined)
|
||||
|
||||
setNotes(validNotes)
|
||||
} catch (err) {
|
||||
console.error('[useConnectionsCompare] Failed to fetch notes:', err)
|
||||
setError('Failed to load notes')
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
fetchNotes()
|
||||
}, [noteIds])
|
||||
|
||||
return { notes, isLoading, error }
|
||||
}
|
||||
Reference in New Issue
Block a user