mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-10 17:08:39 +00:00
Log cleanup
This commit is contained in:
parent
2a35710d79
commit
4bfa31d96e
@ -47,21 +47,17 @@ class UpNextScrubberTouchBarItem: NSCustomTouchBarItem {
|
|||||||
super.init(identifier: identifier)
|
super.init(identifier: identifier)
|
||||||
view = scrollView
|
view = scrollView
|
||||||
// Add event sources
|
// Add event sources
|
||||||
|
// Can optionally pass an update view callback to an event source to redraw element
|
||||||
self.eventSources.append(UpNextCalenderSource(updateCallback: self.updateView))
|
self.eventSources.append(UpNextCalenderSource(updateCallback: self.updateView))
|
||||||
// Add reactivity through interval updates + on calendar change handler
|
// Fallback interactivity via interval
|
||||||
activity.interval = interval
|
activity.interval = interval
|
||||||
activity.repeats = true
|
activity.repeats = true
|
||||||
activity.qualityOfService = .utility
|
activity.qualityOfService = .utility
|
||||||
activity.schedule { (completion: NSBackgroundActivityScheduler.CompletionHandler) in
|
activity.schedule { (completion: NSBackgroundActivityScheduler.CompletionHandler) in
|
||||||
NSLog("---- INTERVAL ----")
|
|
||||||
self.updateView()
|
self.updateView()
|
||||||
completion(NSBackgroundActivityScheduler.Result.finished)
|
completion(NSBackgroundActivityScheduler.Result.finished)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateView()
|
updateView()
|
||||||
|
|
||||||
let upperBoundsDate = Date(timeIntervalSinceNow: futureSearchCutoff)
|
|
||||||
NSLog("Searching up to \(upperBoundsDate)")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder _: NSCoder) {
|
required init?(coder _: NSCoder) {
|
||||||
@ -71,7 +67,6 @@ class UpNextScrubberTouchBarItem: NSCustomTouchBarItem {
|
|||||||
private func updateView() -> Void {
|
private func updateView() -> Void {
|
||||||
items = []
|
items = []
|
||||||
var upcomingEvents = self.getUpcomingEvents()
|
var upcomingEvents = self.getUpcomingEvents()
|
||||||
NSLog("Found \(upcomingEvents.count) events")
|
|
||||||
upcomingEvents.sort(by: {$0.startDate.compare($1.startDate) == .orderedAscending})
|
upcomingEvents.sort(by: {$0.startDate.compare($1.startDate) == .orderedAscending})
|
||||||
var index = 1
|
var index = 1
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
@ -97,7 +92,6 @@ class UpNextScrubberTouchBarItem: NSCustomTouchBarItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func reloadData() {
|
private func reloadData() {
|
||||||
NSLog("Displaying \(items.count) items...")
|
|
||||||
let stackView = NSStackView(views: items.compactMap { $0.view })
|
let stackView = NSStackView(views: items.compactMap { $0.view })
|
||||||
stackView.spacing = 5
|
stackView.spacing = 5
|
||||||
stackView.orientation = .horizontal
|
stackView.orientation = .horizontal
|
||||||
@ -240,7 +234,6 @@ class UpNextCalenderSource : IUpNextSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func getUpcomingEvents(dateLowerBounds: Date, dateUpperBounds: Date) -> [UpNextEventModel] {
|
public func getUpcomingEvents(dateLowerBounds: Date, dateUpperBounds: Date) -> [UpNextEventModel] {
|
||||||
NSLog("Getting calendar events...")
|
|
||||||
var upcomingEvents: [UpNextEventModel] = []
|
var upcomingEvents: [UpNextEventModel] = []
|
||||||
let calendars = self.eventStore.calendars(for: .event)
|
let calendars = self.eventStore.calendars(for: .event)
|
||||||
let predicate = self.eventStore.predicateForEvents(withStart: dateLowerBounds, end: dateUpperBounds, calendars: calendars)
|
let predicate = self.eventStore.predicateForEvents(withStart: dateLowerBounds, end: dateUpperBounds, calendars: calendars)
|
||||||
@ -248,7 +241,6 @@ class UpNextCalenderSource : IUpNextSource {
|
|||||||
for event in events {
|
for event in events {
|
||||||
upcomingEvents.append(UpNextEventModel(title: event.title, startDate: event.startDate, sourceType: UpNextSourceType.iCalendar))
|
upcomingEvents.append(UpNextEventModel(title: event.title, startDate: event.startDate, sourceType: UpNextSourceType.iCalendar))
|
||||||
}
|
}
|
||||||
print("Found " + String(upcomingEvents.count) + " events.")
|
|
||||||
return upcomingEvents
|
return upcomingEvents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user