Skip to content

Commit

Permalink
Don't show all day events in status bar as current event
Browse files Browse the repository at this point in the history
  • Loading branch information
leits committed Jun 1, 2020
1 parent cbfeb7c commit 03d05e8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
21 changes: 15 additions & 6 deletions MeetingBar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {

let eventTimeFormatter = DateFormatter()
eventTimeFormatter.dateFormat = "HH:mm"
let eventStartTime = eventTimeFormatter.string(from: event.startDate)
let eventEndTime = eventTimeFormatter.string(from: event.endDate)
let eventDurationMinutes = String(event.endDate.timeIntervalSince(event.startDate) / 60)

var eventStartTime = ""
if event.isAllDay {
eventStartTime = "All day"
} else {
eventStartTime = eventTimeFormatter.string(from: event.startDate)
}

// Event Item
let itemTitle = "\(eventStartTime) - \(eventTitle)"
Expand Down Expand Up @@ -307,9 +311,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
eventMenu.addItem(NSMenuItem.separator())

// Duration
let durationTitle = "\(eventStartTime) - \(eventEndTime) (\(eventDurationMinutes) minutes)"
eventMenu.addItem(withTitle: durationTitle, action: nil, keyEquivalent: "")
eventMenu.addItem(NSMenuItem.separator())
if !event.isAllDay {
let eventEndTime = eventTimeFormatter.string(from: event.endDate)
let eventDurationMinutes = String(event.endDate.timeIntervalSince(event.startDate) / 60)
let durationTitle = "\(eventStartTime) - \(eventEndTime) (\(eventDurationMinutes) minutes)"
eventMenu.addItem(withTitle: durationTitle, action: nil, keyEquivalent: "")
eventMenu.addItem(NSMenuItem.separator())
}

// Status
if eventStatus != nil {
Expand Down Expand Up @@ -513,6 +521,7 @@ func getNextEvent(eventStore: EKEventStore, calendar: EKCalendar) -> EKEvent? {
// then show the next event
for event in nextEvents {
// Skip event if declined
if event.isAllDay { continue }
if let status = getEventStatus(event) {
if status == .declined { continue }
}
Expand Down
9 changes: 8 additions & 1 deletion MeetingBar/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ struct ContentView: View {
}
Divider()
HStack(alignment: .center) {
Spacer()
Button("About this app", action: about)
Spacer()
Button("Support the creator", action: support)
}
}.padding()
}
Expand All @@ -64,3 +65,9 @@ func about() {
let projectLink = URL(string: "https://github.com/leits/MeetingBar")!
openLinkInDefaultBrowser(projectLink)
}

func support() {
NSLog("User click Support")
let projectLink = URL(string: "https://www.patreon.com/meetingbar")!
openLinkInDefaultBrowser(projectLink)
}

0 comments on commit 03d05e8

Please sign in to comment.