diff --git a/app/actions.ts b/app/actions.ts index 1907580..32ebd5f 100644 --- a/app/actions.ts +++ b/app/actions.ts @@ -34,7 +34,7 @@ export async function sendGotifyNotification(attempts: number, status: 'won' | ' import { PrismaClient } from '@prisma/client'; const prisma = new PrismaClient(); -export async function submitRating(songId: number, rating: number, genre?: string | null) { +export async function submitRating(songId: number, rating: number, genre?: string | null, isSpecial?: boolean, puzzleNumber?: number) { try { const song = await prisma.song.findUnique({ where: { id: songId } }); if (!song) throw new Error('Song not found'); @@ -51,9 +51,17 @@ export async function submitRating(songId: number, rating: number, genre?: strin }); // Send Gotify notification for the rating - const genreText = genre ? `[${genre}] ` : ''; + let context = 'Global Daily Puzzle'; + if (genre) { + context = isSpecial ? `Special Puzzle "${genre}"` : `Genre Puzzle "${genre}"`; + } + if (puzzleNumber) { + context += ` #${puzzleNumber}`; + } + const title = `Hördle Rating: ${rating} Stars`; - const message = `Song "${song.title}" by ${song.artist} ${genreText}received a ${rating}-star rating. (Avg: ${newAverageRating.toFixed(2)}, Count: ${newRatingCount})`; + // Do not show song title/artist to avoid spoilers + const message = `${context} received a ${rating}-star rating.\nNew Average: ${newAverageRating.toFixed(2)} (${newRatingCount} ratings)`; await fetch(`${GOTIFY_URL}/message?token=${GOTIFY_APP_TOKEN}`, { method: 'POST', diff --git a/components/Game.tsx b/components/Game.tsx index bfd1ec8..cbc2dca 100644 --- a/components/Game.tsx +++ b/components/Game.tsx @@ -65,6 +65,17 @@ export default function Game({ dailyPuzzle, genre = null, isSpecial = false, max setLastAction(null); }, [dailyPuzzle?.id]); + useEffect(() => { + if (dailyPuzzle) { + const ratedPuzzles = JSON.parse(localStorage.getItem('hoerdle_rated_puzzles') || '[]'); + if (ratedPuzzles.includes(dailyPuzzle.id)) { + setHasRated(true); + } else { + setHasRated(false); + } + } + }, [dailyPuzzle]); + if (!dailyPuzzle) return (