@@ -5,7 +5,7 @@ import { COLORS } from "../constants";
55import { game } from "../core/Game" ;
66import { authState } from "../managers/AuthStateManager" ;
77import { HtmlOverlay } from "../ui/HtmlOverlay" ;
8- import { ApiError , authApi , dailyApi , type DailyTodayRes } from "../network/rest" ;
8+ import { ApiError , authApi } from "../network/rest" ;
99import { evaluatePassword , PASSWORD_HINT } from "../managers/passwordStrength" ;
1010import { createBetaBadge } from "../ui/pixiBetaBadge" ;
1111
@@ -30,7 +30,6 @@ export class MainMenuScene extends Container implements IScene {
3030 private footerText : Text | null = null ;
3131 private upgradeOverlay : HtmlOverlay | null = null ;
3232 private settingsOverlay : HtmlOverlay | null = null ;
33- private dailyToday : DailyTodayRes | null = null ;
3433
3534 constructor ( app : Application ) {
3635 super ( ) ;
@@ -51,21 +50,19 @@ export class MainMenuScene extends Container implements IScene {
5150 }
5251 this . createUserInfo ( ) ;
5352 this . createFooter ( ) ;
54- // Pull fresh stats (wins) so the counter reflects games played in the
55- // last session — fire-and-forget so the menu still draws instantly.
56- void authState . refresh ( ) . then ( ( ) => this . refreshUserInfo ( ) ) ;
57- // Daily status — also fire-and-forget. Renders the button label as
58- // "Played today" / "Play" and updates the streak line in the corner.
59- void dailyApi
60- . today ( )
61- . then ( ( res ) => {
62- this . dailyToday = res ;
63- this . refreshDailyButton ( ) ;
64- this . refreshStreak ( ) ;
65- } )
66- . catch ( ( ) => {
67- /* leave the button in default "Daily Challenge" state */
68- } ) ;
53+ // Pull fresh /auth/me (wins + daily state) so the counter, daily button,
54+ // and streak line reflect the latest session — fire-and-forget so the menu
55+ // still draws instantly. Daily is bundled into /auth/me (single round
56+ // trip) and the lazy streak reset runs server-side on that call.
57+ void authState . refresh ( ) . then ( ( ) => {
58+ this . refreshUserInfo ( ) ;
59+ this . refreshDailyButton ( ) ;
60+ this . refreshStreak ( ) ;
61+ } ) ;
62+ // Render whatever cached state we already have so the corner labels
63+ // aren't blank during the in-flight refresh.
64+ this . refreshDailyButton ( ) ;
65+ this . refreshStreak ( ) ;
6966 }
7067
7168 private createTitle ( ) : void {
@@ -171,7 +168,7 @@ export class MainMenuScene extends Container implements IScene {
171168 }
172169
173170 private isDailyDisabled ( ) : boolean {
174- return ! ! this . dailyToday ?. played ;
171+ return ! ! authState . getDaily ( ) ?. played ;
175172 }
176173
177174 // (i) icon next to the Daily button. Hover surfaces a small tooltip card
@@ -335,9 +332,10 @@ export class MainMenuScene extends Container implements IScene {
335332
336333 private refreshDailyButton ( ) : void {
337334 if ( ! this . dailyButton ) return ;
338- const played = this . dailyToday ?. played ?? false ;
335+ const daily = authState . getDaily ( ) ;
336+ const played = daily ?. played ?? false ;
339337 const el = this . dailyButton as Container & { __text : Text ; __bg : Graphics } ;
340- const ms = this . dailyToday ?. result ?. elapsedMs ;
338+ const ms = daily ?. result ?. elapsedMs ;
341339 if ( played ) {
342340 this . drawFilledButton ( el . __bg , 250 , 48 , COLORS . surfaceMuted ) ;
343341 el . __bg . stroke ( { color : COLORS . border , width : 1 } ) ;
@@ -354,7 +352,7 @@ export class MainMenuScene extends Container implements IScene {
354352
355353 private refreshStreak ( ) : void {
356354 if ( ! this . streakText ) return ;
357- const cur = this . dailyToday ?. streak . current ?? 0 ;
355+ const cur = authState . getDaily ( ) ?. streak . current ?? 0 ;
358356 this . streakText . text = cur > 0 ? `🔥 ${ cur } -day streak` : "" ;
359357 }
360358
@@ -566,7 +564,7 @@ export class MainMenuScene extends Container implements IScene {
566564 this . addChild ( this . winsText ) ;
567565 nextY += 22 ;
568566
569- // Streak — populated lazily by refreshStreak() once dailyApi.today ()
567+ // Streak — populated lazily by refreshStreak() once authState.refresh ()
570568 // resolves. Empty until then so the corner doesn't flash text.
571569 this . streakText = new Text ( {
572570 text : "" ,
0 commit comments