mirror of
https://github.com/dergigi/boris.git
synced 2025-12-26 11:04:24 +01:00
refactor: remove loading state and show bookmarks as they arrive
- Remove loading state variable from Bookmarks component - Remove 'Loading bookmarks...' screen - Start with empty list and populate bookmarks in background - Remove timeout and loading callbacks from fetchBookmarks - Better UX: show UI immediately, bookmarks appear when ready - Bookmarks.tsx now at 197 lines
This commit is contained in:
@@ -28,7 +28,6 @@ const RELAY_URLS = [
|
||||
|
||||
const Bookmarks: React.FC<BookmarksProps> = ({ relayPool, onLogout }) => {
|
||||
const [bookmarks, setBookmarks] = useState<Bookmark[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [highlights, setHighlights] = useState<Highlight[]>([])
|
||||
const [highlightsLoading, setHighlightsLoading] = useState(true)
|
||||
const [selectedUrl, setSelectedUrl] = useState<string | undefined>(undefined)
|
||||
@@ -69,9 +68,8 @@ const Bookmarks: React.FC<BookmarksProps> = ({ relayPool, onLogout }) => {
|
||||
|
||||
const handleFetchBookmarks = async () => {
|
||||
if (!relayPool || !activeAccount) return
|
||||
const timeoutId = setTimeout(() => setLoading(false), 15000)
|
||||
const fullAccount = accountManager.getActive()
|
||||
await fetchBookmarks(relayPool, fullAccount || activeAccount, setBookmarks, setLoading, timeoutId)
|
||||
await fetchBookmarks(relayPool, fullAccount || activeAccount, setBookmarks)
|
||||
}
|
||||
|
||||
const handleFetchHighlights = async () => {
|
||||
@@ -132,14 +130,6 @@ const Bookmarks: React.FC<BookmarksProps> = ({ relayPool, onLogout }) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="bookmarks-container">
|
||||
<div className="loading">Loading bookmarks...</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={`three-pane ${isCollapsed ? 'sidebar-collapsed' : ''} ${isHighlightsCollapsed ? 'highlights-collapsed' : ''}`}>
|
||||
|
||||
@@ -20,12 +20,9 @@ import { collectBookmarksFromEvents } from './bookmarkProcessing.ts'
|
||||
export const fetchBookmarks = async (
|
||||
relayPool: RelayPool,
|
||||
activeAccount: unknown, // Full account object with extension capabilities
|
||||
setBookmarks: (bookmarks: Bookmark[]) => void,
|
||||
setLoading: (loading: boolean) => void,
|
||||
timeoutId: number
|
||||
setBookmarks: (bookmarks: Bookmark[]) => void
|
||||
) => {
|
||||
try {
|
||||
setLoading(true)
|
||||
|
||||
if (!isAccountWithExtension(activeAccount)) {
|
||||
throw new Error('Invalid account object provided')
|
||||
@@ -62,7 +59,6 @@ export const fetchBookmarks = async (
|
||||
console.log('📋 After deduplication:', bookmarkListEvents.length, 'bookmark events')
|
||||
if (bookmarkListEvents.length === 0) {
|
||||
setBookmarks([])
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
// Aggregate across events
|
||||
@@ -139,12 +135,8 @@ export const fetchBookmarks = async (
|
||||
}
|
||||
|
||||
setBookmarks([bookmark])
|
||||
clearTimeout(timeoutId)
|
||||
setLoading(false)
|
||||
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch bookmarks:', error)
|
||||
clearTimeout(timeoutId)
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user