Skip to content

Follow rdar:// URLs#79

Merged
sberrevoets merged 1 commit intomasterfrom
sb/follow-rdar-urls
Jun 23, 2017
Merged

Follow rdar:// URLs#79
sberrevoets merged 1 commit intomasterfrom
sb/follow-rdar-urls

Conversation

@sberrevoets
Copy link
Copy Markdown
Contributor

@sberrevoets sberrevoets commented Jun 23, 2017

This makes the app responsive to rdar:// URLs. rdar://12345 will open
the app, search OpenRadar for radar 12345, and will display its
contents if available on OpenRadar. The radar can then easily be duped.

Fixes #77


private func registerRadarURLs() {
let eventManager = NSAppleEventManager.shared()
let selector = #selector(handleGetURLEvent(event:withReplyEvent:))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.


@objc
private func handleGetURLEvent(event: NSAppleEventDescriptor, withReplyEvent: NSAppleEventDescriptor) {
let radarID = event.paramDescriptor(forKeyword: keyDirectObject)?.stringValue.flatMap(radarID(from:))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would guard the link separately here so you can put it in the alert window message

} else {
let alert = NSAlert()
alert.messageText = "Invalid Radar ID"
alert.addButton(withTitle: "OK")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this

let radarID = event.paramDescriptor(forKeyword: keyDirectObject)?.stringValue.flatMap(radarID(from:))
if let radarID = radarID {
_ = self.dupeRadarMenuItem.target?.perform(self.dupeRadarMenuItem.action!)
let viewControllers = NSApp.windows.flatMap { $0.contentViewController }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let viewController = NSApp.windows
    .flatMap { $0.contentViewController as? FileDuplicateViewController }
    .first!
viewController.searchForOpenRadar(text: radarID)

?

private func handleGetURLEvent(event: NSAppleEventDescriptor, withReplyEvent: NSAppleEventDescriptor) {
let radarID = event.paramDescriptor(forKeyword: keyDirectObject)?.stringValue.flatMap(radarID(from:))
if let radarID = radarID {
_ = self.dupeRadarMenuItem.target?.perform(self.dupeRadarMenuItem.action!)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would force unwrap target here, this is a programming error if it isn't connected

@keith
Copy link
Copy Markdown
Member

keith commented Jun 23, 2017

Please add changelog entry

@keith
Copy link
Copy Markdown
Member

keith commented Jun 23, 2017

Fixes #77

This makes the app responsive to rdar:// URLs. rdar://12345 will open
the app, search OpenRadar for radar 12345, and will display its
contents if available on OpenRadar. The radar can then easily be duped.
@sberrevoets sberrevoets force-pushed the sb/follow-rdar-urls branch from 80ab34b to 947ac45 Compare June 23, 2017 09:02
@sberrevoets
Copy link
Copy Markdown
Contributor Author

All done

@sberrevoets sberrevoets merged commit 0bf066c into master Jun 23, 2017
@sberrevoets sberrevoets deleted the sb/follow-rdar-urls branch June 23, 2017 09:08
@keith
Copy link
Copy Markdown
Member

keith commented Jun 23, 2017

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants