@@ -140,7 +140,7 @@ define(function (require, exports, module) {
140140 /**
141141 * Shows the sign-in popup when the user is not logged in
142142 */
143- async function showLoginPopup ( ) {
143+ function showLoginPopup ( ) {
144144 // If popup is already visible, just close it
145145 if ( isPopupVisible ) {
146146 closePopup ( ) ;
@@ -150,26 +150,34 @@ define(function (require, exports, module) {
150150 // create the popup element
151151 closePopup ( ) ; // close any existing popup first
152152
153- // Check if non-logged-in user has trial entitlements
154- const effectiveEntitlements = await KernalModeTrust . loginService . getEffectiveEntitlements ( ) ;
155- let templateData = { Strings} ;
156-
157- if ( effectiveEntitlements && effectiveEntitlements . isInProTrial ) {
158- // Add trial information to template data
159- const planName = StringUtils . format ( Strings . PROMO_PRO_TRIAL_DAYS_LEFT ,
160- effectiveEntitlements . trialDaysRemaining ) ;
161- templateData . trialInfo = { planName} ;
162- }
163-
164- // Render template with data
165- const renderedTemplate = Mustache . render ( loginTemplate , templateData ) ;
153+ // Render template with basic data first for instant response
154+ const renderedTemplate = Mustache . render ( loginTemplate , { Strings} ) ;
166155 $popup = $ ( renderedTemplate ) ;
167156
168157 $ ( "body" ) . append ( $popup ) ;
169158 isPopupVisible = true ;
170159
171160 positionPopup ( ) ;
172161
162+ // Check for trial info asynchronously and update popup
163+ KernalModeTrust . loginService . getEffectiveEntitlements ( ) . then ( effectiveEntitlements => {
164+ if ( effectiveEntitlements && effectiveEntitlements . isInProTrial && isPopupVisible && $popup ) {
165+ // Add trial info to the existing popup
166+ const planName = StringUtils . format ( Strings . PROMO_PRO_TRIAL_DAYS_LEFT ,
167+ effectiveEntitlements . trialDaysRemaining ) ;
168+ const trialInfoHtml = `<div class="trial-plan-info">
169+ <span class="phoenix-pro-title-plain">
170+ <span class="pro-plan-name">${ planName } </span>
171+ <i class="fa-solid fa-feather" style="margin-left: 3px;"></i>
172+ </span>
173+ </div>` ;
174+ $popup . find ( '.popup-title' ) . after ( trialInfoHtml ) ;
175+ positionPopup ( ) ; // Reposition after adding content
176+ }
177+ } ) . catch ( error => {
178+ console . error ( 'Failed to check trial info for login popup:' , error ) ;
179+ } ) ;
180+
173181 PopUpManager . addPopUp ( $popup , function ( ) {
174182 $popup . remove ( ) ;
175183 $popup = null ;
@@ -365,7 +373,7 @@ define(function (require, exports, module) {
365373 $planName . addClass ( 'user-plan-paid' ) . html ( proTitle ) ;
366374 } else {
367375 // For paid users: regular plan name with icon
368- const proTitle = `<span class="phoenix-pro-title-plain ">
376+ const proTitle = `<span class="phoenix-pro-title">
369377 <span class="pro-plan-name">${ entitlements . plan . name } </span>
370378 <i class="fa-solid fa-feather" style="margin-left: 3px;"></i>
371379 </span>` ;
@@ -550,20 +558,33 @@ define(function (require, exports, module) {
550558 } ) ;
551559 }
552560
561+ /**
562+ * Check if user has an active trial (works for both logged-in and non-logged-in users)
563+ */
564+ async function _hasActiveTrial ( ) {
565+ try {
566+ const effectiveEntitlements = await KernalModeTrust . loginService . getEffectiveEntitlements ( ) ;
567+ return effectiveEntitlements && effectiveEntitlements . isInProTrial ;
568+ } catch ( error ) {
569+ console . error ( 'Failed to check trial status:' , error ) ;
570+ return false ;
571+ }
572+ }
573+
553574 /**
554575 * Initialize branding for non-logged-in trial users on startup
555576 */
556577 async function _initializeBrandingForTrialUsers ( ) {
557- // Only check if user is not logged in
558- if ( ! KernalModeTrust . loginService . isLoggedIn ( ) ) {
559- try {
560- const effectiveEntitlements = await KernalModeTrust . loginService . getEffectiveEntitlements ( ) ;
561- if ( effectiveEntitlements && effectiveEntitlements . isInProTrial ) {
562- _updateBranding ( effectiveEntitlements ) ;
563- }
564- } catch ( error ) {
565- console . error ( 'Failed to initialize branding for trial users:' , error ) ;
578+ try {
579+ const effectiveEntitlements = await KernalModeTrust . loginService . getEffectiveEntitlements ( ) ;
580+ if ( effectiveEntitlements && effectiveEntitlements . isInProTrial ) {
581+ console . log ( 'Profile Menu: Found active trial, updating branding...' ) ;
582+ _updateBranding ( effectiveEntitlements ) ;
583+ } else {
584+ console . log ( 'Profile Menu: No active trial found' ) ;
566585 }
586+ } catch ( error ) {
587+ console . error ( 'Failed to initialize branding for trial users:' , error ) ;
567588 }
568589 }
569590
@@ -583,6 +604,14 @@ define(function (require, exports, module) {
583604
584605 // Initialize branding for non-logged-in trial users
585606 _initializeBrandingForTrialUsers ( ) ;
607+
608+ // Listen for entitlements changes to update branding for non-logged-in trial users
609+ KernalModeTrust . loginService . on ( KernalModeTrust . loginService . EVENT_ENTITLEMENTS_CHANGED , ( ) => {
610+ // When entitlements change (including trial activation) for non-logged-in users, update branding
611+ if ( ! KernalModeTrust . loginService . isLoggedIn ( ) ) {
612+ _initializeBrandingForTrialUsers ( ) ;
613+ }
614+ } ) ;
586615 }
587616
588617 function setNotLoggedIn ( ) {
@@ -592,11 +621,24 @@ define(function (require, exports, module) {
592621 }
593622 _removeProfileIcon ( ) ;
594623
624+ // Reset branding, but preserve trial branding if user has active trial
625+ _hasActiveTrial ( ) . then ( hasActiveTrial => {
626+ if ( ! hasActiveTrial ) {
627+ // Only reset branding if no trial exists
628+ console . log ( 'Profile Menu: No trial, resetting branding to free' ) ;
629+ _updateBranding ( null ) ;
630+ } else {
631+ // User has trial, maintain pro branding
632+ console . log ( 'Profile Menu: Trial exists, maintaining pro branding' ) ;
633+ _initializeBrandingForTrialUsers ( ) ;
634+ }
635+ } ) . catch ( error => {
636+ console . error ( 'Failed to check trial status during logout:' , error ) ;
637+ // Fallback to resetting branding
638+ _updateBranding ( null ) ;
639+ } ) ;
595640 // Clear cached entitlements when user logs out
596641 KernalModeTrust . loginService . clearEntitlements ( ) ;
597-
598- // Reset branding to free mode
599- _updateBranding ( null ) ;
600642 }
601643
602644 function setLoggedIn ( initial , color ) {
0 commit comments