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

Bug 1897319 - Stores icons for light/dark theme for Yelp suggestion #6248

Closed
wants to merge 2 commits into from

Conversation

dadaa
Copy link
Contributor

@dadaa dadaa commented May 16, 2024

Bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1897319
Jira: https://mozilla-hub.atlassian.net/browse/SNG-1515

We need to update the UI for Yelp suggestion.
One of them is to chnage the logo. But it has to change by the light/dark theme. Thus, make it to store both icons.

This PR did two things.

  1. Stores both icons and change the related codes.
  2. Introduce icon struct as same as PR Bug 1884816 - Expose icon information for suggestion as struct #6162 (A warning that said paramters are too complex in the first commit, it was a good chance :))

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

Branch builds: add [firefox-android: branch-name] to the PR title.

@dadaa dadaa requested review from 0c0w3 and linabutler May 16, 2024 23:47
@codecov-commenter
Copy link

codecov-commenter commented May 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 50.85%. Comparing base (8bd7ba4) to head (1907a14).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6248   +/-   ##
=======================================
  Coverage   50.85%   50.85%           
=======================================
  Files         112      112           
  Lines       11811    11811           
=======================================
  Hits         6006     6006           
  Misses       5805     5805           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@0c0w3 0c0w3 left a comment

Choose a reason for hiding this comment

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

Thanks Daisuke, r+ with comments -- especially, the schema version needs to be bumped and a migration step added.

Copy link
Contributor

Choose a reason for hiding this comment

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

You'll need to bump the schema VERSION const and add a migration step to upgrade_from(). See the comment above VERSION.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for updating all these tests, I know it's pain.

It looks like we now have tests for Yelp suggestions with both light and dark icons, but no tests for only one or the other. Also we may want to keep including icon in the RS data in order to support older Firefox versions for some time, and I want to make sure that doesn't break newer versions.

So could you add cases for the following please, in whatever way is easiest? In all cases, ingest and fetch should complete successfully.

  • Only iconLightTheme is present in the RS data
  • Only iconDarkTheme is present
  • icon, iconLightTheme, and iconDarkTheme are all present (icon should be ignored and ingest and fetch should still be successful)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! Thanks!

Comment on lines +116 to +117
icon_light_theme_id TEXT NOT NULL,
icon_dark_theme_id TEXT NOT NULL,
Copy link
Contributor

Choose a reason for hiding this comment

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

Storing both light and dark icons in the same row is OK with me, and also I just wanted to mention another way to do it would be to have one icon per row plus an "icon type" column. If we need to support any more types of icons in the future -- and I don't know why we would! -- I think we should switch to that approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, if we do not know how many icons we should handle, then yeah, should introduce the mechanism.

Copy link
Contributor

@0c0w3 0c0w3 left a comment

Choose a reason for hiding this comment

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

Thanks, it looks like there are merge conflicts in lib.rs and store.rs, plus some failing tests. Could you fix those and make sure cargo test -p suggest passes locally for you?

@@ -193,6 +195,11 @@ CREATE TABLE IF NOT EXISTS dismissed_suggestions (
)?;
Ok(())
}
19 => {
// Need to update new icons for Yelp especially in new schema.
let _ = clear_database(tx);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since only the Yelp table changed, can we do something like this instead?

  1. If yelp_custom_details exists, get the current record from yelp_custom_details and then DROP TABLE yelp_custom_details
  2. CREATE TABLE yelp_custom_details just like in the main schema SQL
  3. If we got the record from the old table in step 1, insert it into the new table, using the old icon_id as the new icon_light_theme_id

Starting with schema version 16, I believe the idea is to avoid clearing the entire DB on upgrade if possible.

Sorry to add more work but It would also be nice if you could add a test for this migration step too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, thanks!

@dadaa
Copy link
Contributor Author

dadaa commented May 21, 2024

Hi @0c0w3! As I changed more places than I expected, I'd like to request review from you again. Thanks!

@dadaa dadaa requested a review from 0c0w3 May 21, 2024 06:28
@0c0w3
Copy link
Contributor

0c0w3 commented May 21, 2024

Hey @dadaa, Emilio's idea of choosing the appropriate image in the svg itself is really nice, and it means we don't need to modify the schema at all. I'm sorry for not thinking of that, and for all the work you've done in this PR that we might not need.

If you remove the schema change from this PR, it's basically the same as #6162, right?

@dadaa
Copy link
Contributor Author

dadaa commented May 21, 2024

Hey @dadaa, Emilio's idea of choosing the appropriate image in the svg itself is really nice, and it means we don't need to modify the schema at all. I'm sorry for not thinking of that, and for all the work you've done in this PR that we might not need.

Yeah, indeed. I'm also sorry to you that I took your time due to I could not come up with it.

If you remove the schema change from this PR, it's basically the same as #6162, right?

Yes! So, I will close this PR when the bug is fixed.

@dadaa
Copy link
Contributor Author

dadaa commented May 21, 2024

Hey @dadaa, Emilio's idea of choosing the appropriate image in the svg itself is really nice, and it means we don't need to modify the schema at all.

Yeah, indeed. I'm also sorry to you that I took your time due to I could not come up with it.

But, I was a little concerned about whether it would be okay to change the official logo file, even though it would look the same.

@0c0w3
Copy link
Contributor

0c0w3 commented May 21, 2024

I think it's OK to create a new file that combines both official files as long as we don't modify any strokes or colors. My example file in Phabricator embeded only the <path>s from each file, but I think it's possible to embed the whole <svg> from each file inside a <g> in the combined file. That way, we're really not modifying anything at all, only combining.

@dadaa
Copy link
Contributor Author

dadaa commented May 22, 2024

We took another approach, let me close this PR.
https://phabricator.services.mozilla.com/D210745

@dadaa dadaa closed this May 22, 2024
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.

3 participants