This repository has been archived on 2026-05-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
tippspiel/frontend/src/hooks/useRankChange.js
T
Ronny addff8f0cc ci: switch to Gitea Container Registry for reliable deploys
Previous pipeline built images locally via Portainer Docker API,
but Docker layer caching produced identical images. Now:
- Build with nocache=1
- Push to Gitea registry (git.home.rm-warpstation.de)
- Compose uses image: from registry instead of build:
- Redeploy with pullImage: true forces fresh container

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 20:18:34 +02:00

30 lines
1.1 KiB
JavaScript

import { useState, useEffect } from 'react';
import { api } from '../api/client';
const RANK_KEY = 'tippspiel_last_rank';
const SHOWN_KEY = 'tippspiel_rank_toast_shown';
export function useRankChange() {
const [message, setMessage] = useState(null);
useEffect(() => {
// Only show once per session
if (sessionStorage.getItem(SHOWN_KEY))
return;
api.getMyStats().then(stats => {
if (!stats.rank)
return;
const lastRank = parseInt(localStorage.getItem(RANK_KEY) || '0');
if (lastRank > 0 && lastRank !== stats.rank) {
if (stats.rank < lastRank) {
setMessage(`⬆️ Du bist auf Platz ${stats.rank} aufgestiegen!`);
}
else {
setMessage(`⬇️ Du bist auf Platz ${stats.rank} gerutscht — hol dir die Punkte zurück!`);
}
sessionStorage.setItem(SHOWN_KEY, '1');
}
localStorage.setItem(RANK_KEY, String(stats.rank));
}).catch(() => { });
}, []);
function dismiss() { setMessage(null); }
return { message, dismiss };
}