Browse Source

fix bug

drawing-pad
Stephanie Gredell 1 month ago
parent
commit
5b1365d5b5
  1. 4
      frontend/src/config/apps.ts
  2. 16
      frontend/src/hooks/useTimeLimit.ts
  3. 5
      frontend/src/pages/LandingPage.tsx

4
frontend/src/config/apps.ts

@ -16,8 +16,8 @@ export type App = { @@ -16,8 +16,8 @@ export type App = {
export const APPS: App[] = [
{
id: 'videos',
name: 'Video Library',
description: 'Browse long-form videos from your trusted kid-friendly channels, already filtered to longer than ten minutes.',
name: 'Watch Videos',
description: 'Browse long-form videos from your trusted kid-friendly channels.',
cta: 'Open Videos',
link: '/videos',
component: VideoApp

16
frontend/src/hooks/useTimeLimit.ts

@ -33,13 +33,6 @@ export function useTimeLimit(): UseTimeLimitReturn { @@ -33,13 +33,6 @@ export function useTimeLimit(): UseTimeLimitReturn {
const startTimeRef = useRef<number | null>(null);
const lastUpdateRef = useRef<number>(Date.now());
// Fetch limit from server on mount
useEffect(() => {
getDailyLimit().then(limit => {
setDailyLimit(limit);
});
}, []);
// Update state from localStorage and cached server limit
const updateState = useCallback(() => {
setDailyLimit(getDailyLimitSync());
@ -48,6 +41,15 @@ export function useTimeLimit(): UseTimeLimitReturn { @@ -48,6 +41,15 @@ export function useTimeLimit(): UseTimeLimitReturn {
setLimitReached(isLimitReached());
}, []);
// Fetch limit from server on mount
useEffect(() => {
getDailyLimit().then(limit => {
setDailyLimit(limit);
// Immediately recalculate limitReached with the correct server limit
updateState();
});
}, [updateState]);
// Start tracking time
const startTracking = useCallback(() => {
if (limitReached) {

5
frontend/src/pages/LandingPage.tsx

@ -5,11 +5,6 @@ import './LandingPage.css'; @@ -5,11 +5,6 @@ import './LandingPage.css';
export function LandingPage() {
return (
<div className="landing-page menu">
<header className="menu-header">
<h1>Welcome to Kiddos</h1>
<p>Select an app below to get started.</p>
</header>
<section className="app-grid">
{APPS.map(app => (
<article key={app.id} className={`app-card ${app.disabled ? 'disabled' : ''}`}>

Loading…
Cancel
Save