diff --git a/MTMR/Info.plist b/MTMR/Info.plist
index e1bbf12..09a64c8 100644
--- a/MTMR/Info.plist
+++ b/MTMR/Info.plist
@@ -19,7 +19,7 @@
CFBundleShortVersionString
0.26.1
CFBundleVersion
- 405
+ 424
LSApplicationCategoryType
public.app-category.utilities
LSMinimumSystemVersion
diff --git a/MTMR/ItemsParsing.swift b/MTMR/ItemsParsing.swift
index b299877..6ffdc5a 100644
--- a/MTMR/ItemsParsing.swift
+++ b/MTMR/ItemsParsing.swift
@@ -227,7 +227,7 @@ enum ItemType: Decodable {
case network(flip: Bool)
case darkMode
case swipe(direction: String, fingers: Int, minOffset: Float, sourceApple: SourceProtocol?, sourceBash: SourceProtocol?)
- case upnext(from: Double, to: Double, nthEvent: Int)
+ case upnext(from: Double, to: Double, maxToShow: Int)
private enum CodingKeys: String, CodingKey {
case type
@@ -259,7 +259,7 @@ enum ItemType: Decodable {
case direction
case fingers
case minOffset
- case nthEvent
+ case maxToShow
}
enum ItemTypeRaw: String, Decodable {
@@ -385,8 +385,8 @@ enum ItemType: Decodable {
case .upnext:
let from = try container.decodeIfPresent(Double.self, forKey: .from) ?? 0 // Lower bounds of period of time in hours to search for events
let to = try container.decodeIfPresent(Double.self, forKey: .to) ?? 12 // Upper bounds of period of time in hours to search for events
- let nthEvent = try container.decodeIfPresent(Int.self, forKey: .nthEvent) ?? 1 // 1 indexed array. Get the 1st, 2nd, 3rd event to display multiple notifications
- self = .upnext(from: from, to: to, nthEvent: nthEvent)
+ let maxToShow = try container.decodeIfPresent(Int.self, forKey: .maxToShow) ?? 1 // 1 indexed array. Get the 1st, 2nd, 3rd event to display multiple notifications
+ self = .upnext(from: from, to: to, maxToShow: maxToShow)
}
}
}
diff --git a/MTMR/TouchBarController.swift b/MTMR/TouchBarController.swift
index bb613f6..f4e5460 100644
--- a/MTMR/TouchBarController.swift
+++ b/MTMR/TouchBarController.swift
@@ -303,8 +303,8 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
barItem = DarkModeBarItem(identifier: identifier)
case let .swipe(direction: direction, fingers: fingers, minOffset: minOffset, sourceApple: sourceApple, sourceBash: sourceBash):
barItem = SwipeItem(identifier: identifier, direction: direction, fingers: fingers, minOffset: minOffset, sourceApple: sourceApple, sourceBash: sourceBash)
- case let .upnext(from: from, to: to, nthEvent: nthEvent):
- barItem = UpNextBarItem(identifier: identifier, interval: 2, from: from, to: to, nthEvent: nthEvent)
+ case let .upnext(from: from, to: to, maxToShow: maxToShow):
+ barItem = UpNextBarItem(identifier: identifier, interval: 2, from: from, to: to, maxToShow: maxToShow)
}
if let action = self.action(forItem: item), let item = barItem as? CustomButtonTouchBarItem {
diff --git a/MTMR/Widgets/UpNextBarItem.swift b/MTMR/Widgets/UpNextBarItem.swift
index 519c69a..126c59a 100644
--- a/MTMR/Widgets/UpNextBarItem.swift
+++ b/MTMR/Widgets/UpNextBarItem.swift
@@ -20,7 +20,7 @@ class UpNextBarItem: NSCustomTouchBarItem {
// Settings
private var futureSearchCutoff: Double
private var pastSearchCutoff: Double
- private var nthEvent: Int
+ private var maxToShow: Int
private var widthConstraint: NSLayoutConstraint?
/// <#Description#>
@@ -29,17 +29,17 @@ class UpNextBarItem: NSCustomTouchBarItem {
/// - interval: Update view interval in seconds
/// - from: Relative to current time, how far back we search for events in hours
/// - to: Relative to current time, how far forward we search for events in hours
- /// - nthEvent: Which event to show (1 is first, 2 is second, and so on)
- init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, from: Double, to: Double, nthEvent: Int) {
+ /// - maxToShow: Which event to show (1 is first, 2 is second, and so on)
+ init(identifier: NSTouchBarItem.Identifier, interval: TimeInterval, from: Double, to: Double, maxToShow: Int) {
// Initialise member properties
activity = NSBackgroundActivityScheduler(identifier: "\(identifier.rawValue).updateCheck")
pastSearchCutoff = from * 3600
futureSearchCutoff = to * 3600
- self.nthEvent = nthEvent
+ self.maxToShow = maxToShow
UpNextItem.df.dateFormat = "HH:mm"
// Error handling
- if (nthEvent <= 0) {
- fatalError("Error on UpNext bar item. nthEvent property must be greater than 0.")
+ if (maxToShow <= 0) {
+ fatalError("Error on UpNext bar item. maxToShow property must be greater than 0.")
}
// Init super
super.init(identifier: identifier)
@@ -82,7 +82,7 @@ class UpNextBarItem: NSCustomTouchBarItem {
// Add to view
self.items.append(item)
// Check if should display any more
- if (index == self.nthEvent) {
+ if (index == self.maxToShow) {
break;
}
index += 1
diff --git a/README.md b/README.md
index 416ce6c..290e21f 100644
--- a/README.md
+++ b/README.md
@@ -347,13 +347,14 @@ To close a group, use the button:
#### `upnext`
> Calender next event plugin
+Displays upcoming events from MacOS Calendar. Does not display current event
```js
{
"type": "upnext",
- "from": 0, // Lower bound of search range for next event in hours. Default 0 (current time)
- "to": 12, // Upper bounds of search range for next event in hours. Default 12 (12 hours in the future)
- "nthEvent": 1 // Sets this touchbar button to show the nthEvent. Default 1 (the first upcoming event)
+ "from": 0, // Lower bound of search range for next event in hours. Default 0 (current time, can be negative to view events in the past)
+ "to": 12, // Upper bounds of search range for next event in hours. Default 12 (12 hours in the future)
+ "maxToShow": 3 // Limits the maximum number of events displayed. Default 3 (the first 3 upcoming events)
},
```