@@ -393,6 +393,8 @@ export async function updateCrown(dontSave: boolean): Promise<void> {
393393 let pbDiff = 0 ;
394394 const canGetPb = await resultCanGetPb ( ) ;
395395
396+ console . debug ( "Result can get PB:" , canGetPb . value , canGetPb . reason ?? "" ) ;
397+
396398 if ( canGetPb . value ) {
397399 const localPb = await DB . getLocalPB (
398400 Config . mode ,
@@ -406,10 +408,13 @@ export async function updateCrown(dontSave: boolean): Promise<void> {
406408 ) ;
407409 const localPbWpm = localPb ?. wpm ?? 0 ;
408410 pbDiff = result . wpm - localPbWpm ;
411+ console . debug ( "Local PB" , localPb , "diff" , pbDiff ) ;
409412 if ( pbDiff <= 0 ) {
410413 hideCrown ( ) ;
414+ console . debug ( "Hiding crown" ) ;
411415 } else {
412416 //show half crown as the pb is not confirmed by the server
417+ console . debug ( "Showing pending crown" ) ;
413418 showCrown ( "pending" ) ;
414419 updateCrownText (
415420 "+" + Format . typingSpeed ( pbDiff , { showDecimalPlaces : true } )
@@ -428,14 +433,17 @@ export async function updateCrown(dontSave: boolean): Promise<void> {
428433 ) ;
429434 const localPbWpm = localPb ?. wpm ?? 0 ;
430435 pbDiff = result . wpm - localPbWpm ;
436+ console . debug ( "Local PB" , localPb , "diff" , pbDiff ) ;
431437 if ( pbDiff <= 0 ) {
432438 // hideCrown();
439+ console . debug ( "Showing warning crown" ) ;
433440 showCrown ( "warning" ) ;
434441 updateCrownText (
435442 `This result is not eligible for a new PB (${ canGetPb . reason } )` ,
436443 true
437444 ) ;
438445 } else {
446+ console . debug ( "Showing ineligible crown" ) ;
439447 showCrown ( "ineligible" ) ;
440448 updateCrownText (
441449 `You could've gotten a new PB (+${ Format . typingSpeed ( pbDiff , {
@@ -462,14 +470,10 @@ export function showErrorCrownIfNeeded(): void {
462470 ) ;
463471}
464472
465- type CanGetPbObject =
466- | {
467- value : true ;
468- }
469- | {
470- value : false ;
471- reason : string ;
472- } ;
473+ type CanGetPbObject = {
474+ value : boolean ;
475+ reason ?: string ;
476+ } ;
473477
474478async function resultCanGetPb ( ) : Promise < CanGetPbObject > {
475479 const funboxes = result . funbox ?. split ( "#" ) ?? [ ] ;
0 commit comments