Stories: Only show stories for sites that support them#12728
Conversation
|
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
|
You can test the changes on this Pull Request by downloading the APK here. |
| } | ||
|
|
||
| public static boolean supportsStoriesFeature(SiteModel site) { | ||
| return site != null && (site.isWPCom() || checkMinimalJetpackVersion(site, WP_STORIES_JETPACK_VERSION)); |
There was a problem hiding this comment.
TIL about checkMinimalJetpackVersion() and Version() implementation
mzorz
left a comment
There was a problem hiding this comment.
Code LGTM with some notes I'll share in a moment.
Tested the following cases:
- Simple WP.com site -> Story option shown ✅
- Jetpack-connected site, version 8.8+ -> Story option shown ✅
3. Jetpack-connected site, version < 8.8 -> Story option not shown 🙅♂️couldn't test this one but did step by step debugging and observed the checks for minimum version run correctly - Self-hosted site -> Story option not shown 🙅♂️
- (Optional) Atomic on WordPress.com site -> Story option shown ✅ (this is essentially the same as case 2, Atomic sites for this purpose are Jetpack-connected sites kept on the latest stable Jetpack version) --> tried on a Pressable site, works ok
|
tl;dr I think we can keep things as they are, but I had to explore things deeply in order to understand whether the changes here (or even the code as it was in some cases) are in the right direction in terms of code design. I have thoughts about it but aligning to these thoughts most probably means a bigger refactor that exceeds the purpose of this PR. Sharing my thoughts below, feel free to save for later. After a couple of iterations approaching changes to these classes involved in this PR I felt I had a better understanding of how things work here, so I was wondering whether passing a SiteModel to a ViewModel was technically advised, since when the site changes we need to refresh it somehow and make sure the UI changes are triggered, propagating / representing the changes to the ViewModel on the View. Some examples:
Then I realized we're never keeping the selected site on StatsViewAllViewModel has a good example of this in which it gets a StatsSiteProvider injected in its constructor parameters, which in turn encapsulates the interaction in a Repository (in particular the very simple SelectedSiteStorage), and the Provider gets the updates from registering to FluxC If we went down that route, I think not only we would get rid of passing SiteModel, but also would benefit of not having to pass booleans by encapsulating the selectedSite capabilities check logic in the ViewModel, and just rely on the VM and the Activity doing their business as usual given by triggering refreshes though LiveData observers. Open to discussing thoughts and learning from your points of view, but to make it clear I wouldn't block this PR with this discussion 😄 |
I agree completely, I wasn't a big fan of my solution but it felt like an okay interim solution vs adding another boolean to pass to every method. In most other places I'd have gone for injecting the |
👍 Just for future use, I forgot to mention that an easy way to test earlier Jetpack versions is to install the Jetpack beta plugin, that allows you to switch to earlier releases. |
That makes sense - let's merge this then, since it works as expected 😎 |
Fixes Automattic/stories-android#417.
In addition to the check for the stories feature flag being enabled, this PR now checks that the site is able to support the stories feature. This means either:
8.8 is the first Jetpack version to include the story block. The block is flagged as a beta block, which requires some extra steps to actually enable it on the site. When we're ready to release the stories feature, we'll want to update the minimum version set in this PR - this would be the sequence of events:
(This is being tracked on the stories project board.)
I also fixed the description toasts shown when long-pressing the FABs in the main activity and the post list. In the main activity we weren't accounting for stories, and in the post list no toast was being shown at all when stories were enabled.
Also, the FAB tooltip in the post list was always mentioning stories whether the feature was available or not - I fixed this as well.
Only one reviewer is really needed, ccing you @develric in case I missed anything important since I had to restructure
WPMainActivityViewModela bit.To test:
There's no need to test actually pushing a story to the site in this PR - a follow-up PR will remove the gallery fallback logic and call for this kind of test. Any site that isn't Tug's test site will just upload a gallery still as of this PR.
Instead, check that, for each site type:
These are the site type cases.
There's another degree of freedom in the main activity, which is whether the user has the ability to edit pages on the site. If not, there's no bottom sheet in the main activity if stories are disabled or unsupported.
(This is what the unit tests are mostly checking.)
Also check that the option is never shown if the feature flag is disabled, by e.g. setting this to false.
PR submission checklist:
RELEASE-NOTES.txtif necessary.