Browse Source

Show meeting info ~5 minutes after the meeting starts.

pull/101/head
Abhishek 4 years ago
parent
commit
9dd514d3c7
  1. 15
      Clocker/Events and Reminders/CalendarHandler.swift
  2. 6
      Clocker/Panel/ParentPanelController.swift

15
Clocker/Events and Reminders/CalendarHandler.swift

@ -158,7 +158,7 @@ extension EventCenter {
let relevantEvents = filteredEvents[autoupdatingCalendar.startOfDay(for: Date())] ?? [] let relevantEvents = filteredEvents[autoupdatingCalendar.startOfDay(for: Date())] ?? []
let filteredEvent = relevantEvents.filter { let filteredEvent = relevantEvents.filter {
$0.event.isAllDay == false && $0.event.startDate.timeIntervalSinceNow > 0 $0.event.isAllDay == false && $0.event.startDate.timeIntervalSinceNow > -300
}.first }.first
if let firstEvent = filteredEvent { if let firstEvent = filteredEvent {
@ -424,4 +424,17 @@ struct EventInfo {
let isAllDay: Bool let isAllDay: Bool
let isSingleDay: Bool let isSingleDay: Bool
let meetingURL: URL? let meetingURL: URL?
func metadataForMeeting() -> String {
let timeIntervalSinceNowForMeeting = event.startDate.timeIntervalSinceNow
if (timeIntervalSinceNowForMeeting < 0 && timeIntervalSinceNowForMeeting > -300) {
return "Event began \(event.startDate.shortTimeAgoSinceNow) ago."
} else {
let timeSince = Date().timeAgo(since: event.startDate)
let withoutAn = timeSince.replacingOccurrences(of: "an", with: CLEmptyString)
let withoutAgo = withoutAn.replacingOccurrences(of: "ago", with: CLEmptyString)
return "in \(withoutAgo.lowercased())"
}
}
} }

6
Clocker/Panel/ParentPanelController.swift

@ -840,11 +840,7 @@ class ParentPanelController: NSWindowController {
return return
} }
let timeSince = Date().timeAgo(since: upcomingEvent.event.startDate) self.setCalendarButtonTitle(buttonTitle: upcomingEvent.metadataForMeeting())
let withoutAn = timeSince.replacingOccurrences(of: "an", with: CLEmptyString)
let withoutAgo = withoutAn.replacingOccurrences(of: "ago", with: CLEmptyString)
self.setCalendarButtonTitle(buttonTitle: "in \(withoutAgo.lowercased())")
if upcomingEvent.meetingURL != nil { if upcomingEvent.meetingURL != nil {
self.whiteRemoveButton.image = Themer.shared().videoCallImage() self.whiteRemoveButton.image = Themer.shared().videoCallImage()

Loading…
Cancel
Save