Browse Source

Meeting invites!

pull/101/head
Abhishek 4 years ago
parent
commit
fa7ca265d8
  1. 43
      Clocker/Events and Reminders/CalendarHandler.swift
  2. 13
      Clocker/Overall App/Themer.swift
  3. 14
      Clocker/Panel/ParentPanelController.swift

43
Clocker/Events and Reminders/CalendarHandler.swift

@ -201,7 +201,7 @@ extension EventCenter {
for event in events { for event in events {
if selectedCalendars.contains(event.event.calendar.calendarIdentifier) { if selectedCalendars.contains(event.event.calendar.calendarIdentifier) {
if filteredEvents[date] == nil { if filteredEvents[date] == nil {
filteredEvents[date] = [] filteredEvents[date] = Array()
} }
filteredEvents[date]?.append(event) filteredEvents[date]?.append(event)
@ -341,9 +341,9 @@ extension EventCenter {
meetingURL: meetingURL) meetingURL: meetingURL)
return eventInfo return eventInfo
} }
static var dataDetector: NSDataDetector? = nil static var dataDetector: NSDataDetector?
// Borrowing logic from Ityscal // Borrowing logic from Ityscal
@discardableResult @discardableResult
private func findAppropriateURLs(_ description: String) -> URL? { private func findAppropriateURLs(_ description: String) -> URL? {
@ -356,7 +356,7 @@ extension EventCenter {
if actualLink.contains("zoom.us/j/") || actualLink.contains("zoom.us/s/") || actualLink.contains("zoom.us/w/") { if actualLink.contains("zoom.us/j/") || actualLink.contains("zoom.us/s/") || actualLink.contains("zoom.us/w/") {
// Create a Zoom App link // Create a Zoom App link
let workspace = NSWorkspace.shared let workspace = NSWorkspace.shared
if (workspace.urlForApplication(toOpen: URL(string: "zoommtg://")!) != nil) { if workspace.urlForApplication(toOpen: URL(string: "zoommtg://")!) != nil {
actualLink = actualLink.replacingOccurrences(of: "https://", with: "zoommtg://") actualLink = actualLink.replacingOccurrences(of: "https://", with: "zoommtg://")
actualLink = actualLink.replacingOccurrences(of: "?", with: "&") actualLink = actualLink.replacingOccurrences(of: "?", with: "&")
actualLink = actualLink.replacingOccurrences(of: "/j/", with: "/join?confno=") actualLink = actualLink.replacingOccurrences(of: "/j/", with: "/join?confno=")
@ -365,21 +365,20 @@ extension EventCenter {
if let appLink = URL(string: actualLink) { if let appLink = URL(string: actualLink) {
return appLink return appLink
} }
} }
} else if actualLink.contains("zoommtg://") } else if actualLink.contains("zoommtg://")
|| actualLink.contains("meet.google.com/") || actualLink.contains("meet.google.com/")
|| actualLink.contains("hangouts.google.com/") || actualLink.contains("hangouts.google.com/")
|| actualLink.contains("webex.com/") || actualLink.contains("webex.com/")
|| actualLink.contains("gotomeeting.com/join") || actualLink.contains("gotomeeting.com/join")
|| actualLink.contains("ringcentral.com/j") || actualLink.contains("ringcentral.com/j")
|| actualLink.contains("bigbluebutton.org/gl") || actualLink.contains("bigbluebutton.org/gl")
|| actualLink.contains("://bigbluebutton.") || actualLink.contains("://bigbluebutton.")
|| actualLink.contains("://bbb.") || actualLink.contains("://bbb.")
|| actualLink.contains("indigo.collocall.de") || actualLink.contains("indigo.collocall.de")
|| actualLink.contains("public.senfcall.de") || actualLink.contains("public.senfcall.de")
|| actualLink.contains("youcanbook.me/zoom/") || actualLink.contains("youcanbook.me/zoom/")
|| actualLink.contains("workplace.com/groupcall") { || actualLink.contains("workplace.com/groupcall") {
if let zoomLink = result.url { if let zoomLink = result.url {
return zoomLink return zoomLink
} }
@ -388,21 +387,21 @@ extension EventCenter {
} }
return nil return nil
} }
private func retrieveMeetingURL(_ event: EKEvent) -> URL? { private func retrieveMeetingURL(_ event: EKEvent) -> URL? {
if EventCenter.dataDetector == nil { if EventCenter.dataDetector == nil {
// TODO: Handle Try-Catch gracefully // TODO: Handle Try-Catch gracefully
EventCenter.dataDetector = try! NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) EventCenter.dataDetector = try! NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)
} }
if let location = event.location { if let location = event.location {
return findAppropriateURLs(location) return findAppropriateURLs(location)
} }
if let url = event.url { if let url = event.url {
return findAppropriateURLs(url.absoluteString) return findAppropriateURLs(url.absoluteString)
} }
if let notes = event.notes { if let notes = event.notes {
return findAppropriateURLs(notes) return findAppropriateURLs(notes)
} }

13
Clocker/Overall App/Themer.swift

@ -187,8 +187,8 @@ extension Themer {
return return
themeIndex == .light themeIndex == .light
? NSImage(named: NSImage.Name("Settings"))! ? NSImage(named: NSImage.Name("Settings"))!
: NSImage(named: NSImage.Name("Settings-White"))! : NSImage(named: NSImage.Name("Settings-White"))!
} }
func pinImage() -> NSImage { func pinImage() -> NSImage {
@ -442,6 +442,15 @@ extension Themer {
NSColor(deviceRed: 42.0 / 255.0, green: 55.0 / 255.0, blue: 62.0 / 255.0, alpha: 1.0) NSColor(deviceRed: 42.0 / 255.0, green: 55.0 / 255.0, blue: 62.0 / 255.0, alpha: 1.0)
} }
func videoCallImage() -> NSImage? {
if #available(macOS 11.0, *) {
let symbolConfig = NSImage.SymbolConfiguration(pointSize: 20, weight: .regular)
return symbolImage(for: "video.circle.fill")?.withSymbolConfiguration(symbolConfig)
} else {
return nil
}
}
func symbolImage(for name: String) -> NSImage? { func symbolImage(for name: String) -> NSImage? {
assert(name.isEmpty == false) assert(name.isEmpty == false)

14
Clocker/Panel/ParentPanelController.swift

@ -696,6 +696,16 @@ class ParentPanelController: NSWindowController {
func removeUpcomingEventView() { func removeUpcomingEventView() {
OperationQueue.main.addOperation { OperationQueue.main.addOperation {
let eventCenter = EventCenter.sharedCenter()
let now = Date()
if let events = eventCenter.eventsForDate[NSCalendar.autoupdatingCurrent.startOfDay(for: now)], events.isEmpty == false {
guard let upcomingEvent = eventCenter.nextOccuring(events), let meetingLink = upcomingEvent.meetingURL else {
return
}
NSWorkspace.shared.open(meetingLink)
return
}
if self.stackView.arrangedSubviews.contains(self.upcomingEventView!), self.upcomingEventView?.isHidden == false { if self.stackView.arrangedSubviews.contains(self.upcomingEventView!), self.upcomingEventView?.isHidden == false {
self.upcomingEventView?.isHidden = true self.upcomingEventView?.isHidden = true
UserDefaults.standard.set("NO", forKey: CLShowUpcomingEventView) UserDefaults.standard.set("NO", forKey: CLShowUpcomingEventView)
@ -827,6 +837,10 @@ class ParentPanelController: NSWindowController {
let withoutAgo = withoutAn.replacingOccurrences(of: "ago", with: CLEmptyString) let withoutAgo = withoutAn.replacingOccurrences(of: "ago", with: CLEmptyString)
self.setCalendarButtonTitle(buttonTitle: "in \(withoutAgo.lowercased())") self.setCalendarButtonTitle(buttonTitle: "in \(withoutAgo.lowercased())")
if upcomingEvent.meetingURL != nil {
self.whiteRemoveButton.image = Themer.shared().videoCallImage()
}
if #available(OSX 10.14, *) { if #available(OSX 10.14, *) {
PerfLogger.endMarker("Fetch Calendar Events") PerfLogger.endMarker("Fetch Calendar Events")

Loading…
Cancel
Save