@@ -172,6 +172,24 @@ define(function (require, exports, module) {
172172 }
173173 }
174174
175+ /**
176+ * Check if user has active pro subscription
177+ * Returns true if user is logged in and has a paid subscription
178+ */
179+ async function _hasProSubscription ( ) {
180+ try {
181+ // First verify login status to ensure login state is properly resolved
182+ await LoginService . verifyLoginStatus ( ) ;
183+
184+ // getEntitlements() returns null if not logged in
185+ const entitlements = await LoginService . getEntitlements ( ) ;
186+ return entitlements && entitlements . plan && entitlements . plan . paidSubscriber === true ;
187+ } catch ( error ) {
188+ console . error ( "Error checking pro subscription:" , error ) ;
189+ return false ;
190+ }
191+ }
192+
175193 /**
176194 * Check if pro trial is currently activated
177195 */
@@ -205,10 +223,14 @@ define(function (require, exports, module) {
205223 if ( remainingDays <= 0 && ! isNewerVersion ) {
206224 // Check if promo ended dialog was already shown for this version
207225 if ( existingTrialData . upgradeDialogShownVersion !== currentVersion ) {
208- // todo we should not show this to logged in pro subscribers, but at startup time,
209- // we do not know if login is done yet.
210- console . log ( "Existing trial expired, showing promo ended dialog" ) ;
211- ProDialogs . showProEndedDialog ( ) ;
226+ // Check if user has pro subscription before showing promo dialog
227+ const hasProSubscription = await _hasProSubscription ( ) ;
228+ if ( ! hasProSubscription ) {
229+ console . log ( "Existing trial expired, showing promo ended dialog" ) ;
230+ ProDialogs . showProEndedDialog ( ) ;
231+ } else {
232+ console . log ( "Existing trial expired, but user has pro subscription - skipping promo dialog" ) ;
233+ }
212234 // Store that dialog was shown for this version
213235 await _setTrialData ( {
214236 ...existingTrialData ,
@@ -256,7 +278,13 @@ define(function (require, exports, module) {
256278 Metrics . countEvent ( Metrics . EVENT_TYPE . PRO , "trial" , "activated" ) ;
257279 console . log ( `Pro trial activated for ${ trialDays } days` ) ;
258280
259- ProDialogs . showProUpgradeDialog ( trialDays ) ;
281+ // Check if user has pro subscription before showing upgrade dialog
282+ const hasProSubscription = await _hasProSubscription ( ) ;
283+ if ( ! hasProSubscription ) {
284+ ProDialogs . showProUpgradeDialog ( trialDays ) ;
285+ } else {
286+ console . log ( "Pro trial activated, but user has pro subscription - skipping upgrade dialog" ) ;
287+ }
260288 // Trigger the event for UI to handle
261289 LoginService . trigger ( EVENT_PRO_UPGRADE_ON_INSTALL , {
262290 trialDays : trialDays ,
@@ -273,11 +301,14 @@ define(function (require, exports, module) {
273301
274302 /**
275303 * Start the pro trial activation process
276- * Waits 2 minutes, then triggers the upgrade event
277304 */
278305 console . log ( `Checking pro trial activation in ${ TRIAL_POLL_MS / 1000 } seconds...` ) ;
279306
280307 const trialActivatePoller = setInterval ( ( ) => {
308+ if ( Phoenix . isTestWindow ) {
309+ clearInterval ( trialActivatePoller ) ;
310+ return ;
311+ }
281312 if ( _isAnyDialogsVisible ( ) ) {
282313 // maybe the user hasn't dismissed the new project dialog
283314 return ;
0 commit comments