Skip to content

Commit

Permalink
Merge pull request #26 from betzerra/feat-16-person-meetings
Browse files Browse the repository at this point in the history
Feat #16: Filter one person meetings on clipboard and time spent summary
  • Loading branch information
betzerra committed Nov 12, 2021
2 parents b815c26 + 9272dc0 commit 794de7e
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 28 deletions.
2 changes: 2 additions & 0 deletions Morty.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.betzerra.Morty;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -561,6 +562,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.betzerra.Morty;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
89 changes: 71 additions & 18 deletions Morty/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions Morty/CalendarPicker/CalendarPickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
//

import AppKit
import Combine
import Foundation
import EventKit

class CalendarPickerViewController: NSViewController, NSTableViewDataSource, NSTableViewDelegate {

@IBOutlet weak var filterOnePersonMeetingsCheckbox: NSButton!
@IBOutlet weak var allowButton: NSButton!
@IBOutlet weak var tableView: NSTableView!
let viewModel = CalendarPickerViewModel()
Expand All @@ -19,6 +21,7 @@ class CalendarPickerViewController: NSViewController, NSTableViewDataSource, NST
super.viewDidLoad()

updateAllowButton()
updateFilterOnePersonMeetingsCheckbox()

tableView.dataSource = self
tableView.delegate = self
Expand All @@ -28,6 +31,13 @@ class CalendarPickerViewController: NSViewController, NSTableViewDataSource, NST
allowButton.title = EventsManager.isAuthorized ? "Granted" : "Allow"
}

private func updateFilterOnePersonMeetingsCheckbox() {
filterOnePersonMeetingsCheckbox.state = AppDelegate
.current
.settings
.filterOnePersonMeetings ? .on : .off
}

@IBAction func allowButtonPressed(_ sender: Any) {
AppDelegate
.current
Expand All @@ -40,6 +50,14 @@ class CalendarPickerViewController: NSViewController, NSTableViewDataSource, NST
})
}

@IBAction func onePersonMeetingsCheckboxChanged(_ sender: Any) {
guard let button = sender as? NSButton else {
return
}

AppDelegate.current.settings.filterOnePersonMeetings = button.state == .on
}

// MARK: NSTableViewDataSource

func numberOfRows(in tableView: NSTableView) -> Int {
Expand Down
14 changes: 7 additions & 7 deletions Morty/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSUIElement</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>NSContactsUsageDescription</key>
<string>Morty needs access to your contacts in order to display them on the app</string>
<key>NSCalendarsUsageDescription</key>
<string>Morty needs access to your calendar in order to display them on the app</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
Expand All @@ -23,11 +17,17 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
<true/>
<key>NSCalendarsUsageDescription</key>
<string>Morty needs access to your calendar in order to display them on the app</string>
<key>NSContactsUsageDescription</key>
<string>Morty needs access to your contacts in order to display them on the app</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
Expand Down
11 changes: 9 additions & 2 deletions Morty/Managers/EventsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,17 @@ class EventsManager {
.map { _ in () }
.eraseToAnyPublisher()

Publishers.Merge3(
// Fetch events when filter one person meetings changed
let filterOnePersonMeetingsChanged: AnyPublisher<(), Never> = settings
.$filterOnePersonMeetings
.map { _ in () }
.eraseToAnyPublisher()

Publishers.Merge4(
timerPublisher,
eventStoreChanged,
selectedCalendarsChanged
selectedCalendarsChanged,
filterOnePersonMeetingsChanged
)
.receive(on: RunLoop.main)
.sink { [weak self] _ in
Expand Down
9 changes: 9 additions & 0 deletions Morty/Managers/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ class Settings {
}
}

@Published var filterOnePersonMeetings: Bool = false {
willSet {
Settings.saveValue(setting: newValue, forKey: .filterOnePersonMeetings)
}
}

var cancellables = [AnyCancellable]()

// Try to keep all the keys sorted alphabetically :-)
enum Key: String {
case enabledCalendars
case filterOnePersonMeetings
}

// This will force developer to use always Settings.fromUserDefaults()
Expand All @@ -33,6 +40,8 @@ class Settings {
settings.enabledCalendars = tmp
}

settings.filterOnePersonMeetings = Settings.loadValue(forKey: .filterOnePersonMeetings) ?? false

return settings
}

Expand Down
12 changes: 12 additions & 0 deletions Morty/MenuView/MenuDayViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,19 @@ class MenuDayViewModel {
return

case .someEvents(let events, let timeSpent):
let filterOnePersonMeetings = AppDelegate
.current
.settings
.filterOnePersonMeetings

var text = events
.filter({ event in
guard filterOnePersonMeetings else {
return true
}

return event.type != .onePerson
})
.map { $0.standupText }
.joined(separator: "\n")

Expand Down
2 changes: 1 addition & 1 deletion Morty/Models/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct Event: Codable, Hashable {
/// Tells if the event should be included
/// in "time spent" summary
var takesTime: Bool {
return type != .allDay
return type == .meeting || (type == .onePerson && !AppDelegate.current.settings.filterOnePersonMeetings)
}

func isDuplicate(of event: Event) -> Bool {
Expand Down

0 comments on commit 794de7e

Please sign in to comment.