From de769aca7177f1b7da7e4c895842167414d21f9a Mon Sep 17 00:00:00 2001 From: Michele Date: Mon, 6 Apr 2026 02:06:16 +0200 Subject: [PATCH] fix: persist saved idea state across navigation, fix UTC timestamp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Dashboard: track saved ideas in React state (Set), compare against suggestion texts to show "✓ Salvata" persistently - Backend: append 'Z' to saved_at ISO timestamp so JS parses as UTC (fixes "2h fa" bug for UTC+2 users) Co-Authored-By: Claude Opus 4.6 (1M context) --- backend/app/routers/content.py | 2 +- frontend/src/components/Dashboard.jsx | 48 +++++++++++++++++---------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/backend/app/routers/content.py b/backend/app/routers/content.py index 8c9fc31..673756a 100644 --- a/backend/app/routers/content.py +++ b/backend/app/routers/content.py @@ -493,7 +493,7 @@ def save_idea( "id": str(uuid.uuid4())[:8], "text": text, "note": data.get("note", ""), - "saved_at": datetime.utcnow().isoformat(), + "saved_at": datetime.utcnow().isoformat() + "Z", "used": False, } ideas.insert(0, new_idea) diff --git a/frontend/src/components/Dashboard.jsx b/frontend/src/components/Dashboard.jsx index 79cfeb5..e210a28 100644 --- a/frontend/src/components/Dashboard.jsx +++ b/frontend/src/components/Dashboard.jsx @@ -15,6 +15,7 @@ export default function Dashboard() { const [loading, setLoading] = useState(true) const [suggestions, setSuggestions] = useState(null) const [suggestionsLoading, setSuggestionsLoading] = useState(false) + const [savedTexts, setSavedTexts] = useState(new Set()) useEffect(() => { Promise.all([ @@ -38,6 +39,12 @@ export default function Dashboard() { setRecentPosts(posts.slice(0, 5)) setProviderStatus(providers) setLoading(false) + // Load saved ideas to know which suggestions are already saved + api.get('/content/ideas').then(data => { + const texts = new Set((data.ideas || []).map(i => i.text)) + setSavedTexts(texts) + }).catch(() => {}) + // Load cached suggestions (won't regenerate if already generated today) if (providers?.llm?.configured && chars.length > 0) { setSuggestionsLoading(true) @@ -170,24 +177,29 @@ export default function Dashboard() { > Genera → - + {savedTexts.has(topic) ? ( + + ✓ Salvata + + ) : ( + + )} ))}