Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Fix pushing Issues VC when user taps on username in referenced issues #2766

Merged
merged 5 commits into from
Jun 2, 2019

Conversation

natharateh
Copy link
Contributor

This fixes #2260. 🤞

When user taps IssueReferencedCell, 2 competing delegates can be notified -

  1. UICollectionViewDelegate
  2. MarkdownStyledTextViewDelegate

When both delegates are notified (for example when user taps username in a referenced issue), UICollectionViewDelegate (IssueReferencedSectionController) will push a new IssuesViewController :

viewController?.route_push(to: IssuesViewController(client: client, model: model))

and MarkdownStyledTextViewDelegate (IssuesViewController) will present a profile via SFSafariViewController :

case .username(let username): presentProfile(login: username)

Since IssueReferencedSectionController implements UICollectionViewDelegate, I made it conform to the competing delegate (MarkdownStyledTextViewDelegate) so that we can figure out which delegate should proceed - if we're notified that username was tapped, we'll present the profile VC and set a flag that will prevent the other delegate from pushing the Issues VC.

Let me know if there's a better way to do this. 🤔

@BasThomas BasThomas added the 💤 awaiting review Pull Request is awaiting code reviews label Jun 2, 2019
Copy link
Member

@jdisho jdisho left a comment

Choose a reason for hiding this comment

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

The solution looks good to me. However, I have one question.
Shouldn’t we also set shouldShowIssueOnItemSelection to false on cases like email, url and commit? 🤔

@natharateh
Copy link
Contributor Author

natharateh commented Jun 2, 2019

Good point @jdisho 🤔 Maybe we could use the result of handle(attribute: DetectedMarkdownAttribute) -> Bool to set shouldShowIssueOnItemSelection? That handles all the cases we care about - url, email, username and commit :

func handle(attribute: DetectedMarkdownAttribute) -> Bool {

So something like

    func didTap(cell: MarkdownStyledTextView, attribute: DetectedMarkdownAttribute) {
        guard let viewController = viewController else {
            return
        }
        shouldShowIssueOnItemSelection = !viewController.handle(attribute: attribute)
    }

If the attribute can be handled, handle will do the work & return true, if not, we'll allow didSelectItem to proceed. What do you think?

@jdisho
Copy link
Member

jdisho commented Jun 2, 2019

Nice one @nambatee!
I think we can continue with this suggestion 👍

@natharateh
Copy link
Contributor Author

Thanks @jdisho! 😄 Pushed it in b79d0aa

@jdisho
Copy link
Member

jdisho commented Jun 2, 2019

Awesome! Thank you @nambatee

@jdisho jdisho merged commit 90cc726 into GitHawkApp:master Jun 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💤 awaiting review Pull Request is awaiting code reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Name and underlying button getting called
3 participants