Skip to content

Commit

Permalink
Fix redundant ask to enable dailyReminders (#679)
Browse files Browse the repository at this point in the history
^ALTAPPS-990
  • Loading branch information
XanderZhu authored Sep 26, 2023
1 parent e445a58 commit 9245fc0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,15 @@ class NotificationInteractor(
return false
}

if (submissionRepository.getSolvedStepsCount() <= 1L) {
return true
}
val isFirstStepSolved = submissionRepository.getSolvedStepsCount() >= 1L

val lastTimeAsked = notificationRepository.getLastTimeUserAskedToEnableDailyReminders() ?: return true
val isTwoDaysPassed = (lastTimeAsked + TWO_DAYS_IN_MILLIS) <= Clock.System.now().toEpochMilliseconds()
val isAskedAtLeastTwoDaysAgo = (lastTimeAsked + TWO_DAYS_IN_MILLIS) <= Clock.System.now().toEpochMilliseconds()

val isNotReachedMaxUserAskedCount =
getUserAskedToEnableDailyRemindersCount() < MAX_USER_ASKED_TO_ENABLE_DAILY_REMINDERS_COUNT

return isTwoDaysPassed && isNotReachedMaxUserAskedCount
return isFirstStepSolved && isAskedAtLeastTwoDaysAgo && isNotReachedMaxUserAskedCount
}

fun updateLastTimeUserAskedToEnableDailyReminders() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal class NotificationsOnboardingReducer : StateReducer<State, Message, Act
HyperskillAnalyticRoute.Onboarding.Notifications
)
),
InternalAction.UpdateLastNotificationPermissionRequestTime,
Action.ViewAction.RequestNotificationPermission
)
is Message.NotificationPermissionRequestResult ->
Expand All @@ -35,14 +36,14 @@ internal class NotificationsOnboardingReducer : StateReducer<State, Message, Act
isAllowed = message.isPermissionGranted
)
),
InternalAction.UpdateLastNotificationPermissionRequestTime,
Action.ViewAction.CompleteNotificationOnboarding
)
Message.RemindMeLaterClicked ->
setOf(
InternalAction.LogAnalyticsEvent(
NotificationsOnboardingClickedRemindMeLaterHyperskillAnalyticsEvent
),
InternalAction.UpdateLastNotificationPermissionRequestTime,
Action.ViewAction.CompleteNotificationOnboarding
)
Message.ViewedEventMessage ->
Expand Down

0 comments on commit 9245fc0

Please sign in to comment.