Skip to content

Commit

Permalink
Fix overdue time showing when not supposed to
Browse files Browse the repository at this point in the history
  • Loading branch information
pakerwreah committed Oct 13, 2024
1 parent 9de7fa0 commit 0949b3e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Calendr/Events/EventList/EventViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class EventViewModel {
let isPast: Observable<Bool>
let clock: Observable<Void>

if secondsToEnd > 0 {
if isTodaySelected, !event.isAllDay, secondsToEnd > 0, event.type != .reminder(completed: true) {

isPast = Observable<Int>.timer(.seconds(secondsToEnd), scheduler: scheduler)
.map(true)
Expand Down Expand Up @@ -206,8 +206,10 @@ class EventViewModel {
dateFormatter.unitsStyle = .abbreviated
dateFormatter.allowedUnits = [.hour, .minute]

relativeDuration = clock.map {
Strings.Formatter.Date.Relative.ago(
relativeDuration = clock.compactMap {
guard event.start.distance(to: dateProvider.now) > 60 else { return nil }

return Strings.Formatter.Date.Relative.ago(
dateFormatter.string(from: event.start, to: dateProvider.now) ?? ""
)
}
Expand Down

0 comments on commit 0949b3e

Please sign in to comment.