From c3b653601cbf8fdb2604d24b06be306ad2bb0493 Mon Sep 17 00:00:00 2001 From: Froidefond Julien Date: Tue, 3 Mar 2026 11:18:11 +0100 Subject: [PATCH] fix: notes patching in weather --- src/components/weather/WeatherCard.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/weather/WeatherCard.tsx b/src/components/weather/WeatherCard.tsx index 7ab0fce..95545c6 100644 --- a/src/components/weather/WeatherCard.tsx +++ b/src/components/weather/WeatherCard.tsx @@ -105,20 +105,22 @@ export const WeatherCard = memo(function WeatherCard({ const [fluxEmoji, setFluxEmoji] = useState(entry.fluxEmoji || null); const [valueCreationEmoji, setValueCreationEmoji] = useState(entry.valueCreationEmoji || null); - // Reset local state when entry props change (React-idiomatic pattern) + const isCurrentUser = entry.userId === currentUserId; + const canEditThis = canEdit && isCurrentUser; + + // Sync state when props change from SSE refresh. + // Notes are NOT synced for the current user's own entry — they may be mid-edit. if (entryVersion !== entry) { setEntryVersion(entry); - setNotes(entry.notes || ''); + if (!isCurrentUser) setNotes(entry.notes || ''); setPerformanceEmoji(entry.performanceEmoji || null); setMoralEmoji(entry.moralEmoji || null); setFluxEmoji(entry.fluxEmoji || null); setValueCreationEmoji(entry.valueCreationEmoji || null); } - const isCurrentUser = entry.userId === currentUserId; - const canEditThis = canEdit && isCurrentUser; - function handleEmojiChange( + axis: 'performance' | 'moral' | 'flux' | 'valueCreation', emoji: string | null ) {