mirror of
https://github.com/dergigi/boris.git
synced 2026-01-20 23:34:52 +01:00
feat(highlights): force synchronous render for immediate highlight display
- Use flushSync to force React to render synchronously after highlight creation - Eliminates render cycle delay for instant visual feedback - Highlights now appear immediately in the text when created
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useCallback, useRef } from 'react'
|
||||
import { flushSync } from 'react-dom'
|
||||
import { RelayPool } from 'applesauce-relay'
|
||||
import { NostrEvent } from 'nostr-tools'
|
||||
import { IEventStore } from 'applesauce-core'
|
||||
@@ -84,7 +85,11 @@ export const useHighlightCreation = ({
|
||||
}
|
||||
|
||||
highlightButtonRef.current?.clearSelection()
|
||||
onHighlightCreated(newHighlight)
|
||||
|
||||
// Force synchronous render to show highlight immediately
|
||||
flushSync(() => {
|
||||
onHighlightCreated(newHighlight)
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('❌ Failed to create highlight:', error)
|
||||
// Re-throw to allow parent to handle
|
||||
|
||||
Reference in New Issue
Block a user