Skip to content

Commit

Permalink
Notify about already started sessions and sessions starting in less t…
Browse files Browse the repository at this point in the history
…han 5 minutes

It might be not super useful, it's more like an Easter egg, for fun.
  • Loading branch information
bashor committed May 22, 2024
1 parent 675ca7e commit e7b9f32
Showing 1 changed file with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,27 @@ class ConferenceService(
private fun scheduleNotification(session: SessionCardView) {
if (!notificationsAllowed) return

val startTimestamp = session.startsAt.timestamp - 5 * 60 * 1000
val delay = startTimestamp - now().timestamp
if (delay < 0) {
return
}
val startTimestamp = session.startsAt.timestamp
val reminderTimestamp = startTimestamp - 5 * 60 * 1000
val nowTimestamp = now().timestamp
val delay = reminderTimestamp - nowTimestamp
val voteTimeStamp = session.endsAt.timestamp

notificationManager.schedule(delay, session.title, "Starts in 5 minutes.")
when {
delay >= 0 -> {
notificationManager.schedule(delay, session.title, "Starts in 5 minutes.")
}
nowTimestamp in reminderTimestamp..<startTimestamp -> {
notificationManager.schedule(0, session.title, "The session is about to start.")
}
nowTimestamp in startTimestamp..<voteTimeStamp -> {
notificationManager.schedule(0, session.title, "Hurry up! The session has already started!")
}
}

val voteTimeStamp = session.endsAt.timestamp
val voteDelay = voteTimeStamp - now().timestamp
if (nowTimestamp > voteTimeStamp) return

val voteDelay = voteTimeStamp - nowTimestamp
notificationManager.schedule(
voteDelay,
"${session.title} finished",
Expand Down

0 comments on commit e7b9f32

Please sign in to comment.