-
Notifications
You must be signed in to change notification settings - Fork 130
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
[Blaze] Logic for the MyStore's View when there is no campaign #9966
Conversation
18257fd
to
50ea7cf
Compare
} | ||
} | ||
|
||
sealed interface MyStoreBlazeCampaignState { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the state to a sealed interface, this IMO simplifies the logic a bit, since there is no more duplication around the product itself, and it's also simpler for dealing when there are no active products (instead of making an additional field nullable).
Please let me know if you prefer keeping it the way it was.
@@ -79,32 +79,49 @@ fun MyStoreBlazeView( | |||
) | |||
BlazeProductItem( | |||
product = state.product, | |||
onProductSelected = {}, | |||
onProductSelected = state.onCreateCampaignClicked, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might change depending on what Ann says here p1697457385386219-slack-C03L1NF1EA3
).filterNot { it.isSampleProduct } | ||
return flow { | ||
emit(getCachedProducts()) | ||
productListRepository.fetchProductList( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the function's return as Flow to allow fetching products and updating the UI, let me know what you think about the logic.
50ea7cf
to
a6700a5
Compare
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
This was causing issues with unit tests, probably because Mockito is still not a Kotlin library
Divider() | ||
WCTextButton( | ||
modifier = Modifier.padding(start = dimensionResource(id = R.dimen.major_75)), | ||
onClick = onCreateCampaignClicked |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JorgeMucientes I noticed that this function was emiting multiple UI elements, so it depends on the parent Composable for defining how they will be laid out, AFAIK this is not recommended, since it's hard to predict, and maintain (any change to the parent layout will impact it, but it's not easy to figure out why).
I can't find any explicit mention of this in the official guideline, but I think it can still be inferred from the fact that Component composables need to accept a Modifier
argument, so they need to emit a single UI element which will consume it 🤔, and I also found this lint rule in Slack's repo which protects against such usage.
WDYT? do you agree with this opinion? and do you think it's worth adding an explicit mention of this to our guidelines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify further, I updated it because I needed adding a top padding, so it was a chance to refactor it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! We actually do have a rule for that in the guidelines, only that I missed it. In fact, now that I see this, I remember adding fun ColumnScope.CreateCampaignFooter
, but since I wasn't making any use of the scope inside the function I had to remove it.
Anyway I agree with your refactor and thanks for adding the missing Modifie
param 👍🏼
The instrumented tests are failling, I'll investigate it ASAP, but the rest of the PR is ready for review. |
d2253bd
to
034431c
Compare
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/ObserveMostRecentBlazeCampaign.kt
Show resolved
Hide resolved
034431c
to
4bb0b4d
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## trunk #9966 +/- ##
============================================
- Coverage 43.10% 43.06% -0.05%
Complexity 4604 4604
============================================
Files 946 947 +1
Lines 50909 50962 +53
Branches 6596 6604 +8
============================================
+ Hits 21943 21945 +2
- Misses 27105 27156 +51
Partials 1861 1861
☔ View full report in Codecov by Sentry. |
Found 1 violations: The PR caused the following dependency changes:expand
-+--- org.wordpress:fluxc:2.50.0
-| +--- org.wordpress:wellsql:2.0.0
-| | +--- androidx.annotation:annotation:1.2.0 -> 1.6.0 (*)
-| | \--- org.wordpress.wellsql:wellsql-annotations:2.0.0
-| +--- org.wordpress.fluxc:fluxc-annotations:2.50.0
-| +--- org.greenrobot:eventbus:3.3.1 (*)
-| +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.11.0 (*)
-| +--- com.android.volley:volley:1.1.1 -> 1.2.0
-| +--- androidx.paging:paging-runtime:2.1.2
-| | +--- androidx.paging:paging-common:2.1.2
-| | | +--- androidx.annotation:annotation:1.0.0 -> 1.6.0 (*)
-| | | \--- androidx.arch.core:core-common:2.0.0 -> 2.1.0 (*)
-| | +--- androidx.arch.core:core-runtime:2.0.0 -> 2.1.0 (*)
-| | +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.5.1 (*)
-| | +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.5.1 (*)
-| | \--- androidx.recyclerview:recyclerview:1.0.0 -> 1.2.1 (*)
-| +--- com.goterl:lazysodium-android:5.0.2
-| +--- net.java.dev.jna:jna:5.5.0
-| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.20 -> 1.8.21 (*)
-| +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.6.20 -> 1.8.21
-| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.8.21 (*)
-| +--- androidx.appcompat:appcompat:1.0.2 -> 1.4.2 (*)
-| +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.2.1 (*)
-| +--- androidx.exifinterface:exifinterface:1.0.0 -> 1.3.3
-| | \--- androidx.annotation:annotation:1.2.0 -> 1.6.0 (*)
-| +--- androidx.security:security-crypto:1.0.0 -> 1.1.0-alpha03
-| | +--- androidx.annotation:annotation:1.1.0 -> 1.6.0 (*)
-| | +--- com.google.crypto.tink:tink-android:1.5.0
-| | \--- androidx.collection:collection:1.1.0 -> 1.2.0 (*)
-| +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.0
-| | +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.11.0 (*)
-| | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10 -> 1.8.21 (*)
-| +--- com.google.code.gson:gson:2.8.5 -> 2.10.1
-| +--- org.apache.commons:commons-text:1.10.0 (*)
-| +--- androidx.room:room-runtime:2.4.2 -> 2.5.1 (*)
-| +--- androidx.room:room-ktx:2.4.2 -> 2.5.1
-| | +--- androidx.room:room-common:2.5.1 (*)
-| | +--- androidx.room:room-runtime:2.5.1 (*)
-| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 -> 1.8.21 (*)
-| | \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4 (*)
-| +--- com.google.dagger:dagger:2.42 -> 2.46.1
-| | \--- javax.inject:javax.inject:1
-| +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.6.4 (*)
-| \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.6.4 (*)
++--- org.wordpress:fluxc:trunk-3caf1058bd9384da8a134cee9855c92e31e7ff5f
+| +--- org.wordpress:wellsql:2.0.0
+| | +--- androidx.annotation:annotation:1.2.0 -> 1.6.0 (*)
+| | \--- org.wordpress.wellsql:wellsql-annotations:2.0.0
+| +--- org.wordpress.fluxc:fluxc-annotations:trunk-3caf1058bd9384da8a134cee9855c92e31e7ff5f
+| +--- org.greenrobot:eventbus:3.3.1 (*)
+| +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.11.0 (*)
+| +--- com.android.volley:volley:1.1.1 -> 1.2.0
+| +--- androidx.paging:paging-runtime:2.1.2
+| | +--- androidx.paging:paging-common:2.1.2
+| | | +--- androidx.annotation:annotation:1.0.0 -> 1.6.0 (*)
+| | | \--- androidx.arch.core:core-common:2.0.0 -> 2.1.0 (*)
+| | +--- androidx.arch.core:core-runtime:2.0.0 -> 2.1.0 (*)
+| | +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.5.1 (*)
+| | +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.5.1 (*)
+| | \--- androidx.recyclerview:recyclerview:1.0.0 -> 1.2.1 (*)
+| +--- com.goterl:lazysodium-android:5.0.2
+| +--- net.java.dev.jna:jna:5.5.0
+| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.20 -> 1.8.21 (*)
+| +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.6.20 -> 1.8.21
+| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.8.21 (*)
+| +--- androidx.appcompat:appcompat:1.0.2 -> 1.4.2 (*)
+| +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.2.1 (*)
+| +--- androidx.exifinterface:exifinterface:1.0.0 -> 1.3.3
+| | \--- androidx.annotation:annotation:1.2.0 -> 1.6.0 (*)
+| +--- androidx.security:security-crypto:1.0.0 -> 1.1.0-alpha03
+| | +--- androidx.annotation:annotation:1.1.0 -> 1.6.0 (*)
+| | +--- com.google.crypto.tink:tink-android:1.5.0
+| | \--- androidx.collection:collection:1.1.0 -> 1.2.0 (*)
+| +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.0
+| | +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.11.0 (*)
+| | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10 -> 1.8.21 (*)
+| +--- com.google.code.gson:gson:2.8.5 -> 2.10.1
+| +--- org.apache.commons:commons-text:1.10.0 (*)
+| +--- androidx.room:room-runtime:2.4.2 -> 2.5.1 (*)
+| +--- androidx.room:room-ktx:2.4.2 -> 2.5.1
+| | +--- androidx.room:room-common:2.5.1 (*)
+| | +--- androidx.room:room-runtime:2.5.1 (*)
+| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 -> 1.8.21 (*)
+| | \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4 (*)
+| +--- com.google.dagger:dagger:2.42 -> 2.46.1
+| | \--- javax.inject:javax.inject:1
+| +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.6.4 (*)
+| \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.6.4 (*)
-\--- org.wordpress.fluxc.plugins:woocommerce:2.50.0
- +--- org.wordpress:wellsql:2.0.0 (*)
- +--- org.wordpress.fluxc:fluxc-annotations:2.50.0
- +--- androidx.room:room-ktx:2.4.2 -> 2.5.1 (*)
- +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.20 -> 1.8.21 (*)
- +--- org.wordpress:fluxc:2.50.0 (*)
- +--- com.google.code.gson:gson:2.8.5 -> 2.10.1
- +--- com.google.dagger:dagger:2.42 -> 2.46.1 (*)
- +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.6.4 (*)
- +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.6.4 (*)
- \--- androidx.room:room-runtime:2.4.2 -> 2.5.1 (*)
+\--- org.wordpress.fluxc.plugins:woocommerce:trunk-3caf1058bd9384da8a134cee9855c92e31e7ff5f
+ +--- org.wordpress:wellsql:2.0.0 (*)
+ +--- org.wordpress.fluxc:fluxc-annotations:trunk-3caf1058bd9384da8a134cee9855c92e31e7ff5f
+ +--- androidx.room:room-ktx:2.4.2 -> 2.5.1 (*)
+ +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.20 -> 1.8.21 (*)
+ +--- org.wordpress:fluxc:trunk-3caf1058bd9384da8a134cee9855c92e31e7ff5f (*)
+ +--- com.google.code.gson:gson:2.8.5 -> 2.10.1
+ +--- com.google.dagger:dagger:2.42 -> 2.46.1 (*)
+ +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.6.4 (*)
+ +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.6.4 (*)
+ \--- androidx.room:room-runtime:2.4.2 -> 2.5.1 (*)
Please review and act accordingly
|
# Conflicts: # WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/MyStoreBlazeView.kt # WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/MyStoreBlazeViewModel.kt # WooCommerce/src/main/kotlin/com/woocommerce/android/ui/mystore/MyStoreFragment.kt
956e4ad
to
89da3a7
Compare
Generated by 🚫 dangerJS |
Excellent job @hichamboushaba! Code looks great and everything works as expected. |
Closes: #9959
Description
This PR adds the logic for the MyStore's Blaze View in the no-campaign state, it adds the following:
Testing instructions
RELEASE-NOTES.txt
if necessary.