woocommerce-android icon indicating copy to clipboard operation
woocommerce-android copied to clipboard

Blaze: Fix a crash when no ad suggestions

Open 0nko opened this issue 1 year ago • 4 comments

This PR fixes a crash when there are no ad suggestions in the ad-edit screen.

To test:

Online

  1. Start a campaign creation
  2. Tap on the Edit ad button
  3. Notice that 3 suggestions are loaded
  4. Edit something and tap save
  5. Notice the ad details are updated
  6. Tap on the Edit ad button again
  7. Notice the correct details are loaded
  8. Tap on the arrows and notice the other 3 suggestions are available

Offline

  1. Turn on the flight mode
  2. Start a campaign creation
  3. Tap on the Edit ad button
  4. Notice the AI suggestions row is not displayed
  5. Add suggestion details and save
  6. Notice the details are updated
  7. Tap on the Edit ad button again
  8. Notice the correct details are loaded

0nko avatar Feb 16 '24 17:02 0nko

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
FlavorJalapeno
Build TypeDebug
Commit752fe032dc2c3067b4395d4ae40247fce122dc77
Direct Downloadwoocommerce-prototype-build-pr10853-752fe03.apk

wpmobilebot avatar Feb 16 '24 17:02 wpmobilebot

Hey @0nko I think I fixed this already as part of this PR:https://github.com/woocommerce/woocommerce-android/pull/10820 Specifically in this commit: https://github.com/woocommerce/woocommerce-android/pull/10820/commits/c726565a6458a988c0eaab9f7a41191c23d66feb, where AI suggestions are passed as navArgs from CampaignPreviewFragment to EditAdFragment. The reason for this where to avoid doing unnecessary requests.

So, I'm unsure this is needed. I tested following the steps shared in the description and the app doesn't crash with this PR's code https://github.com/woocommerce/woocommerce-android/pull/10820

Let me know if I missed something and I can address it :)

JorgeMucientes avatar Feb 16 '24 17:02 JorgeMucientes

@JorgeMucientes did you test the offline case, because I'm not sure your changes will fix this case though, as the passed suggestions will still be empty when we get an error. But TBH, I didn't review the whole code yet, just wondering.

hichamboushaba avatar Feb 16 '24 17:02 hichamboushaba

Codecov Report

Attention: Patch coverage is 0% with 15 lines in your changes are missing coverage. Please review.

Project coverage is 40.89%. Comparing base (bd1eab8) to head (c79edd3).

:exclamation: Current head c79edd3 differs from pull request most recent head 752fe03. Consider uploading reports for the commit 752fe03 to get more accurate results

Files Patch % Lines
...reation/ad/BlazeCampaignCreationEditAdViewModel.kt 0.00% 15 Missing :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #10853      +/-   ##
============================================
- Coverage     41.44%   40.89%   -0.56%     
+ Complexity     5114     5017      -97     
============================================
  Files          1036     1026      -10     
  Lines         59885    59211     -674     
  Branches       8051     7913     -138     
============================================
- Hits          24821    24215     -606     
- Misses        32848    32850       +2     
+ Partials       2216     2146      -70     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Feb 16 '24 17:02 codecov-commenter

Hey @hichamboushaba resuming this discussion :)

did you test the offline case, because I'm not sure your changes will fix this case though, as the passed suggestions will still be empty when we get an error. But TBH, I didn't review the whole code yet, just wondering.

Yes, the changes added there fix the crash. It's not really about passing the suggestions from the preview screen to the edit ad screen; that fixed the problem. It was a small refactor done on how the suggestion list is processed that fixed it.

The following screencast was recorded from this PR: #10926

https://github.com/woocommerce/woocommerce-android/assets/2663464/62e2894d-ff08-4101-ba36-583d5d73fd9f

@0nko I think we can discard the changes added to BlazeCampaignCreationEditAdViewModel and keep only the changes applied to the screen UI code to hide the suggestions row if the ai suggestion list is empty.

JorgeMucientes avatar Feb 26 '24 17:02 JorgeMucientes

1 Warning
:warning: This PR is assigned to the milestone 17.6. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by :no_entry_sign: Danger

dangermattic avatar Feb 28 '24 13:02 dangermattic

@JorgeMucientes I've updated the code, ready for a review.

0nko avatar Feb 28 '24 13:02 0nko

The code looks great, and everything works as expected! Thanks @0nko 👍🏼

JorgeMucientes avatar Feb 28 '24 17:02 JorgeMucientes