Skip to content

Commit 55f8802

Browse files
committed
Update promo cards
1 parent 10c6091 commit 55f8802

1 file changed

Lines changed: 13 additions & 48 deletions

File tree

app/lib/screens/lesson_select_screen.dart

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ class _LessonSelectScreenState extends State<LessonSelectScreen>
372372
}
373373
}
374374

375-
/// Determines whether to show a promo card based on probability and user interaction history
375+
/// Determines whether to show a promo card
376376
bool _shouldShowPromoCard(SettingsProvider settings) {
377377
// Check if user is not logged in - if so, always show account creation promo
378378
final isLoggedIn = Supabase.instance.client.auth.currentUser != null;
@@ -381,48 +381,7 @@ class _LessonSelectScreenState extends State<LessonSelectScreen>
381381
}
382382

383383
// 10% chance to show a popup (only for logged-in users)
384-
if (Random().nextInt(10) != 0) {
385-
return false;
386-
}
387-
388-
// For donation popup
389-
if (_shouldHidePromo(
390-
settings.lastDonationPopup, settings.hasClickedDonationLink)) {
391-
return false;
392-
}
393-
394-
// For follow popup
395-
if (_shouldHidePromo(
396-
settings.lastFollowPopup, settings.hasClickedFollowLink)) {
397-
return false;
398-
}
399-
400-
// For satisfaction popup
401-
if (_shouldHidePromo(
402-
settings.lastSatisfactionPopup, settings.hasClickedSatisfactionLink)) {
403-
return false;
404-
}
405-
406-
// For difficulty feedback popup
407-
if (_shouldHidePromo(
408-
settings.lastDifficultyPopup, settings.hasClickedDifficultyLink)) {
409-
return false;
410-
}
411-
412-
// If we get here, we can show a popup
413-
return true;
414-
}
415-
416-
/// Checks if a specific promo should be hidden based on last popup date and click status
417-
bool _shouldHidePromo(DateTime? lastPopup, bool hasClickedLink) {
418-
if (!hasClickedLink || lastPopup == null) {
419-
return false; // Don't hide if not clicked or no previous popup date
420-
}
421-
422-
final now = DateTime.now();
423-
final nextAllowed =
424-
DateTime(lastPopup.year, lastPopup.month + 1, 1); // First of next month
425-
return now.isBefore(nextAllowed);
384+
return Random().nextInt(10) == 0;
426385
}
427386

428387
PromoType _determinePromoType() {
@@ -431,11 +390,17 @@ class _LessonSelectScreenState extends State<LessonSelectScreen>
431390
return PromoType.accountCreation;
432391
}
433392

434-
final rand = Random().nextDouble();
435-
if (rand < 0.125) return PromoType.donation;
436-
if (rand < 0.25) return PromoType.difficulty;
437-
if (rand < 0.375) return PromoType.satisfaction;
438-
return PromoType.follow;
393+
final rand = Random().nextInt(4);
394+
switch (rand) {
395+
case 0:
396+
return PromoType.donation;
397+
case 1:
398+
return PromoType.difficulty;
399+
case 2:
400+
return PromoType.satisfaction;
401+
default:
402+
return PromoType.follow;
403+
}
439404
}
440405

441406
void _trackPromoCardShown() {

0 commit comments

Comments
 (0)