Skip to content

Commit

Permalink
ALTAPPS-890: Fix Android daily reminder (#590)
Browse files Browse the repository at this point in the history
^ALTAPPS-890 Needs testing
  • Loading branch information
XanderZhu authored Jul 18, 2023
1 parent f8bb121 commit a3f6979
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,19 @@ class DailyStudyReminderLocalNotificationDelegate(
}

override fun getNextScheduledAt(): Long? =
getNextScheduledAtInternal()

fun scheduleDailyNotification() {
getNextScheduledAtInternal()?.let { scheduledAt ->
scheduleNotificationAt(scheduledAt)
}
}

private fun getNextScheduledAtInternal(): Long? {
if (!notificationInteractor.isDailyStudyRemindersEnabled()) {
return null
null
} else {
getNextScheduledAtInternal(notificationInteractor.getDailyStudyRemindersIntervalStartHour())
}

val hour = notificationInteractor.getDailyStudyRemindersIntervalStartHour()
fun scheduleDailyNotification(
selectedHour: Int = notificationInteractor.getDailyStudyRemindersIntervalStartHour()
) {
scheduleNotificationAt(getNextScheduledAtInternal(selectedHour))
}

private fun getNextScheduledAtInternal(hour: Int): Long {
val now = DateTimeHelper.nowUtc()
val calendar = Calendar.getInstance()
calendar.set(Calendar.HOUR_OF_DAY, hour)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class ProfileFragment :
profileViewModel.onNewMessage(
ProfileFeature.Message.DailyStudyRemindersIntervalStartHourChanged(chosenInterval)
)
platformNotificationComponent.dailyStudyReminderNotificationDelegate.scheduleDailyNotification()
platformNotificationComponent.dailyStudyReminderNotificationDelegate.scheduleDailyNotification(chosenInterval)
}

override fun onAction(action: ProfileFeature.Action.ViewAction) {
Expand Down

0 comments on commit a3f6979

Please sign in to comment.