Skip to content

Commit

Permalink
Merge pull request #66 from dev10110/hidePastEvents
Browse files Browse the repository at this point in the history
Allows hiding past events
  • Loading branch information
leits authored Sep 21, 2020
2 parents 5d90585 + a26b0d8 commit e008b55
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions MeetingBar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
var timeFormatObserver: DefaultsObservation?
var eventTitleFormatObserver: DefaultsObservation?
var disablePastEventObserver: DefaultsObservation?
var hidePastEventObserver: DefaultsObservation?
var declinedEventsAppereanceObserver: DefaultsObservation?
var showEventsForPeriodObserver: DefaultsObservation?
var joinEventNotificationObserver: DefaultsObservation?
Expand Down Expand Up @@ -108,6 +109,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
NSLog("Changed disablePastEvents from \(change.oldValue) to \(change.newValue)")
self.statusBarItem.updateMenu()
}
hidePastEventObserver = Defaults.observe(.hidePastEvents) { change in
NSLog("Changed hidePastEvents from \(change.oldValue) to \(change.newValue)")
self.statusBarItem.updateMenu()
}
declinedEventsAppereanceObserver = Defaults.observe(.declinedEventsAppereance) { change in
NSLog("Changed declinedEventsAppereance from \(change.oldValue) to \(change.newValue)")
self.statusBarItem.updateMenu()
Expand Down
1 change: 1 addition & 0 deletions MeetingBar/DefaultsKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extension Defaults.Keys {
static let showEventDetails = Key<Bool>("showEventDetails", default: false)
static let declinedEventsAppereance = Key<DeclinedEventsAppereance>("declinedEventsAppereance", default: .strikethrough)
static let disablePastEvents = Key<Bool>("disablePastEvents", default: true)
static let hidePastEvents = Key<Bool>("hidePastEvents", default: false)
static let timeFormat = Key<TimeFormat>("timeFormat", default: .military)

// Integrations
Expand Down
4 changes: 4 additions & 0 deletions MeetingBar/PreferencesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ struct Appearance: View {
@Default(.showEventDetails) var showEventDetails
@Default(.declinedEventsAppereance) var declinedEventsAppereance
@Default(.disablePastEvents) var disablePastEvents
@Default(.hidePastEvents) var hidePastEvents

var body: some View {
VStack(alignment: .leading, spacing: 15) {
Expand Down Expand Up @@ -234,6 +235,9 @@ struct Appearance: View {
Spacer()
Toggle("Show event details as submenu", isOn: $showEventDetails)
}
HStack{
Toggle("Hide past events", isOn: $hidePastEvents)
}
HStack {
Picker("Declined events:", selection: $declinedEventsAppereance) {
Text("show with strikethrough").tag(DeclinedEventsAppereance.strikethrough)
Expand Down
6 changes: 6 additions & 0 deletions MeetingBar/StatusBarItemControler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ class StatusBarItemControler {
}

let now = Date()

if Defaults[.hidePastEvents]{
if event.endDate < now {
return
}
}

let eventTitle = String(event.title)

Expand Down

0 comments on commit e008b55

Please sign in to comment.