Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[NT-644] See all project category fix #1061

Merged
merged 11 commits into from
Feb 13, 2020
Merged

Conversation

cdolm92
Copy link
Contributor

@cdolm92 cdolm92 commented Feb 6, 2020

📲 What

See all [Category] projects button does not work on Thanks Page, this PR fixes that issue.

🤔 Why

Used ThanksCategoryCellDelegate so that ThanksViewController dismisses and user sees all projects in a category when See all [Category] projects button is tapped.

🛠 How

More in-depth discussion of the change or implementation.

👀 See

Trello, screenshots, external resources?

Before 🐛 After 🦋
thanks-button-bug thanks-button-fix

✅ Acceptance criteria

  • Go through checkout flow, on Thanks screen tap See all [Category] projects. Thanks Screen dismisses you should be at the category explore screen.

@cdolm92 cdolm92 added the blocked a PR that is blocked for external reasons label Feb 6, 2020
@cdolm92 cdolm92 marked this pull request as ready for review February 6, 2020 21:24
@cdolm92 cdolm92 requested a review from Scollaco February 6, 2020 21:34
@cdolm92 cdolm92 removed the blocked a PR that is blocked for external reasons label Feb 10, 2020
Copy link
Contributor

@justinswart justinswart left a comment

Choose a reason for hiding this comment

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

Thanks I think it's good that the cell is backed with a VM now and tested. I just think it would be good if we could align the naming conventions for the buttons and inputs, there are several variations in different places.

@@ -3,14 +3,48 @@ import Library
import Prelude
import UIKit

internal protocol ThanksCategoryCellDelegate: AnyObject {
func thanksSeeAllProjectsTapped(_ cell: ThanksCategoryCell, category: KsApi.Category)
Copy link
Contributor

Choose a reason for hiding this comment

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

How about:

func thanksCategoryCell(_ cell: ThanksCategoryCell, didTapSeeAllProjectsWith category: KsApi.Category)

internal weak var delegate: ThanksCategoryCellDelegate?
fileprivate let viewModel: ThanksCategoryCellViewModelType = ThanksCategoryCellViewModel()

@IBOutlet fileprivate var seeAllProjectCategoryButton: UIButton!
Copy link
Contributor

Choose a reason for hiding this comment

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

Some places in this file we use (see all) project singular and other places projects plural. Would be nice to just have one convention.

Also is the name seeAllProjectsButton not more accurate here? Or perhaps seeAllProjectsInCategoryButton (feels a bit long)?

}

@objc fileprivate func seeAllProjectCategoryTapped() {
self.viewModel.inputs.allProjectCategoryButtonTapped()
Copy link
Contributor

Choose a reason for hiding this comment

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

Here there is just an inconsistency between the function name and the input name, so if you could align those to match with all other places that would be cool.


extension ThanksViewController: ThanksCategoryCellDelegate {
func thanksSeeAllProjectsTapped(_: ThanksCategoryCell, category: KsApi.Category) {
self.viewModel.inputs.categoryCellTapped(category)
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is an existing input but could also be good to align this naming with the delegate method naming once that's updated 🤷‍♂

import ReactiveSwift

public protocol ThanksCategoryCellViewModelInputs {
func allProjectCategoryButtonTapped()
Copy link
Contributor

Choose a reason for hiding this comment

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

This can also update once the button naming is update to match.

}

public protocol ThanksCategoryCellViewModelOutputs {
var notifyToGoToDiscovery: Signal<KsApi.Category, Never> { get }
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be notifyDelegateToGoToDiscovery?

@justinswart justinswart assigned justinswart and unassigned Scollaco Feb 11, 2020
@@ -3,14 +3,48 @@ import Library
import Prelude
import UIKit

internal protocol ThanksCategoryCellDelegate: AnyObject {
func thanksSeeAllProjectsTapped(_ cell: ThanksCategoryCell, category: KsApi.Category)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think delegate method names usually follow the convention of starting the delegate name with the name of the class that's sending the message:

func thanksCategoryCell(_ cell: ThanksCategoryCell, didTapSeeAllProjectsWith category: KsApi.Category)

.observeForControllerAction()
.observeValues { [weak self] in
guard let _self = self else { return }
self?.delegate?.thanksSeeAllProjectsTapped(_self, category: $0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here you could just call _self.delegate?.thanksSeeAllProjectsTapped(_self: category: $0) since you unwrap self in the previous line.

}

public protocol ThanksCategoryCellViewModelOutputs {
var notifyToGoToDiscovery: Signal<KsApi.Category, Never> { get }
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this could be notifyDelegateGoToDiscovery so we're specific about what object is being notified.

@@ -35,7 +35,7 @@
<edgeInsets key="layoutMargins" top="16" left="16" bottom="16" right="16"/>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<connections>
<outlet property="seeAllProjectsButton" destination="hbb-GW-PrV" id="Sfl-8U-s0p"/>
<outlet property="seeAllProjectCategoryButton" destination="hbb-GW-PrV" id="RPG-Zr-HaH"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be projects plural? seeAllProjectsCategoryButton 🤔

@cdolm92 cdolm92 requested a review from justinswart February 13, 2020 17:25
self.viewModel.outputs.notifyDelegateToGoToDiscovery
.observeForControllerAction()
.observeValues { [weak self] in
guard let _self = self else { return }
Copy link
Contributor

Choose a reason for hiding this comment

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

By the way, Swift now lets us do guard let self = self else { ... } for this sort of thing.

@cdolm92 cdolm92 merged commit 2301025 into master Feb 13, 2020
@cdolm92 cdolm92 deleted the NT-644-thanks-button-fix branch February 13, 2020 21:02
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants