mirror of https://github.com/usememos/memos.git
Implement real-time memo synchronization across all open browser instances using Server-Sent Events (SSE). When a memo is created, updated, or deleted on one device, all other connected clients receive the change notification and automatically refresh their data. Backend changes: - Add SSEHub (pub/sub) for broadcasting memo change events to connected clients - Add SSE HTTP endpoint at /api/v1/sse with Bearer token authentication (supports both Authorization header and query parameter for EventSource) - Broadcast memo.created, memo.updated, and memo.deleted events from the memo service after successful operations - Include SSEHub in APIV1Service and wire it into server initialization - Update test helper to include SSEHub to prevent nil pointer panics Frontend changes: - Add useLiveMemoRefresh hook that connects to SSE endpoint using fetch ReadableStream (supports custom auth headers unlike native EventSource) - Automatically invalidate React Query caches on received events: - memo.created: invalidate memo lists + user stats - memo.updated: invalidate specific memo detail + memo lists - memo.deleted: remove memo from cache + invalidate lists + user stats - Exponential backoff reconnection (1s to 30s) on connection failures - Integrate hook in AppInitializer for app-wide live refresh - Add SSE-specific Vite dev proxy config with no timeout for streaming Co-authored-by: milvasic <milvasic@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| test | ||
| acl_config.go | ||
| acl_config_test.go | ||
| activity_service.go | ||
| attachment_exif_test.go | ||
| attachment_service.go | ||
| auth_service.go | ||
| auth_service_client_info_test.go | ||
| common.go | ||
| connect_handler.go | ||
| connect_interceptors.go | ||
| connect_services.go | ||
| header_carrier.go | ||
| health_service.go | ||
| idp_service.go | ||
| instance_service.go | ||
| memo_attachment_service.go | ||
| memo_relation_service.go | ||
| memo_service.go | ||
| memo_service_converter.go | ||
| memo_service_filter.go | ||
| reaction_service.go | ||
| resource_name.go | ||
| shortcut_service.go | ||
| sse_handler.go | ||
| sse_hub.go | ||
| user_service.go | ||
| user_service_stats.go | ||
| v1.go | ||