firefox-ios
firefox-ios copied to clipboard
Refactor FXIOS-9833 General favicon related improvements to SiteImageModel and related classes
:scroll: Tickets
:bulb: Description
Note to self: I have the merge destination currently set to my other favicon refactor branch so the changes can be more clearly reviewed. But merge in FXIOS-9667 fix first.
Apologies for the long PR. 🙈 Most of the changes are naming improvements. Half the changes are in the unit tests.
General refactoring for some things I noticed while finishing up the favicon rework:
- Simplified
SiteImageModelso it won't be possible to get empty cache key strings, empty resource URL strings, String and URL representation of the same data (siteURL,siteURLString), etc. - Generalized
SiteImageModelso it has a single resource URL rather than separate hero and favicon URLs (it only has one type after all...) and a non-optionalsiteURL(doesn't make sense to have aSiteImageModelif no site) - Moved cache key generation to the
SiteImageModeland vastly simplified the logic (seemed unnecessarily complicated). Made sure all code needing cache keys calls this method. - Updated "site" param naming to be "model" when passing around a
SiteImageModel(siteis misleading) - Methods prefixed with "getURL" or "getImage" that actually returned a
SiteImageModelnow return what they say they're returning (e.g. aURL, aUIImage, etc.) - Instead of passing around
.absoluteStringof several URLs, just pass around theURLto avoid redundant conversions - Updated some documentation that referred to old code
- Remove optionals where there was no need to be optional
- Add a guard so we don't try to cache empty faviconURLs from the
Tabmetadata updatedidSetafter loading a webpage - Prefer modern concurrency to execute UI updates on the main thread instead of GCD (especially when inside a Task)
- Removed unnecessary do/catch blocks, or moved them to be more contextual with what they were wrapping
- Unit test updates.
SiteImageHandlerTestsno longer test the exact same things asImageHandlerTests(hence deleted tests). - Added a few FIXMEs for discussion
:pencil: Checklist
You have to check all boxes before merging
- [x] Filled in the above information (tickets numbers and description of your work)
- [x] Updated the PR name to follow our PR naming guidelines
- [x] Wrote unit tests and/or ensured the tests suite is passing
- [ ] When working on UI, I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
- [ ] If needed, I updated documentation / comments for complex code and public methods
- [ ] If needed, added a backport comment (example
@Mergifyio backport release/v120)