Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(dashdirect): add login function with temporary UI #1068

Merged
merged 6 commits into from
Dec 17, 2022

Conversation

hadia
Copy link
Contributor

@hadia hadia commented Dec 6, 2022

Issue being fixed or feature implemented

Add sign in dialog for dashdirect Api

Related PR's and Dependencies

Screenshots / Videos

How Has This Been Tested?

  • QA (Mobile Team)

Checklist:

  • I have performed a self-review of my own code and added comments where necessary
  • I have added or updated relevant unit/integration/functional/e2e tests

Copy link
Member

@Syn-McJ Syn-McJ left a comment

Choose a reason for hiding this comment

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

Some changes needed.

@@ -111,6 +111,9 @@ public class Configuration {
public static final String PREFS_KEY_HAS_LOCATION_DIALOG_BEEN_SHOWN = "has_location_dialog_been_shown";
public static final String PREFS_KEY_EXPLORE_DATABASE_NAME = "explore_database_name";

// DashDirect
public static final String PREFS_KEY_LAST_DASHDIRECT_ACCESS_TOKEN = "last_dash_direct_access_token";
Copy link
Member

Choose a reason for hiding this comment

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

@hadia let's not add any new prefs into this file, it will end up being very large otherwise. We want to move feature-specific preferences into dedicated datastore configs. Please see CoinbaseConfig and CrowdNodeConfig for reference.

So you can create an ExploreConfig for all of the explore preferences and put this in there. The rest of Explore prefs will be migrated there with time.

Comment on lines 529 to 535
viewModel.dashDirectSignIn.observe(viewLifecycleOwner) {
if (it) {
// TODO open Buy card UI
Toast.makeText(requireContext(), "Open Buy Card", Toast.LENGTH_SHORT).show()
viewModel.logEvent(AnalyticsConstants.Explore.MERCHANT_DETAILS_BUY_GIFT_CARD)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

The pattern of calling a function and observing result in LiveData is not great. It makes the execution flow more complicated and hard to track.

Instead, simply call a suspend function in a lifecycleScope and process the result.

Comment on lines 209 to 211
private val _dashDirectSignIn = MutableLiveData<Boolean>()
val dashDirectSignIn: LiveData<Boolean>
get() = _dashDirectSignIn
Copy link
Member

Choose a reason for hiding this comment

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

You don't need this. See below.

return
}

viewModelScope.launch {
Copy link
Member

Choose a reason for hiding this comment

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

Just make signInToDashDirect suspend and return the result directly. See below.

@hadia hadia requested a review from Syn-McJ December 6, 2022 15:01
Copy link
Member

@Syn-McJ Syn-McJ left a comment

Choose a reason for hiding this comment

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

This is better. Some more points to improve in the future:

  • runBlocking usage is discouraged. It's better to have the method that deals with settings as suspend. Reading from prefs is a IO operation and should be treated in an async manner.
  • Returning ResponseResource from the viewModel method is unnecessary. Just return the result or throw an error, then try/catch in the caller.

@HashEngineering
Copy link
Collaborator

The base branch is called feature/DashDirect which doesn't follow our feature-* nameing scheme which is required to activate CI.

@HashEngineering HashEngineering changed the base branch from feature/DashDirect to feature-dashdirect December 17, 2022 01:57
@HashEngineering HashEngineering changed the title feat (dash direct): login feat (dashdirect): add login function with temporary UI Dec 17, 2022
@HashEngineering HashEngineering changed the title feat (dashdirect): add login function with temporary UI feat(dashdirect): add login function with temporary UI Dec 17, 2022
@HashEngineering
Copy link
Collaborator

new branch created named feature-dashdirect

@HashEngineering HashEngineering merged commit f634197 into feature-dashdirect Dec 17, 2022
@Syn-McJ Syn-McJ deleted the feature/NMI-719_dash_direct_login branch January 3, 2023 06:55
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.

None yet

3 participants