mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-12 16:37:06 +02:00
Comprehensive improvements to the republish feature for production deployment: **Performance Optimizations**: - Use useMemo for expensive computations (seenRelays, connectedRelays, allRelays) - Use useCallback for event handlers to prevent unnecessary re-renders - Memoize connected relays filter to avoid duplicate array operations - Reduce re-renders by caching computed values **Better Error Handling**: - Add try-catch with proper error logging to console - Extract error messages consistently across handlers - Add .catch() to relay fetch promise for graceful failures - Prevent duplicate publish operations with guard clauses **Accessibility Improvements**: - Add aria-labels to all interactive buttons with descriptive text - Add role="group" to relay sections for screen readers - Add role="status" to empty state message - Add aria-hidden="true" to decorative icons - Add type="button" to prevent form submission - Add focus ring styles for keyboard navigation **Code Quality**: - Add JSDoc comments to all handler functions - Better variable naming (isPublishing flag, connectedRelays) - Consolidate duplicate code (connected relays filter) - Improve code organization with clear sections - Remove magic numbers and duplicate logic **Edge Cases**: - Check isPublishing before starting batch publish - Check publishingRelays.has(relay) before individual publish - Handle relay fetch errors gracefully without crashing - Proper state cleanup in finally blocks **State Management**: - Consistent state updates using functional updates - Proper Set operations for tracking publishing/published states - Clear separation between local UI state and event state All tests pass and build succeeds. Code is now production-ready.