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

Fixes: site monitor prevent webview reload #20077

Merged
merged 33 commits into from
Jan 31, 2024

Conversation

AjeshRPai
Copy link
Contributor

@AjeshRPai AjeshRPai commented Jan 30, 2024

Fixes

#20067

Description

This PR fixes the issue of reloading of the webviews in site monitoring activity when the tabs are selected again.

Screen_recording_20240131_151636.webm

Pending issues

  • [Fixed] On Loading of the Webview first time - there is a glitch happening (not sure if its because of the emulator or something else)

To Test:

Prerequisite

◐ Toggle the site_monitoring flag
  1. Go to MeApp SettingsDebug settingsRemote Feature Flags
  2. Tap on the item corresponding to the flag - site_monitoring
  3. Tap RESTART THE APP button

Site monitor webviews are not re-loaded when selected again

  1. Go to More → Site Monitoring
  2. ✅ Verify that the logs include tracking 🔵 Tracked: site_monitoring_screen_shown
  3. ✅ Verify that for each tab - Metrics, PHP logs and Web Server logs, the webview loads from the network first time
  4. ✅ Verify that on changing tab, the logs include tracking - `🔵 Tracked: site_monitoring_tab_shown, Properties: {"tab":"php_logs"}
  5. ✅ Verify that when the tabs are selected again, the webviews are not reloaded
    `

Regression Notes

  1. Potential unintended areas of impact
  • Site monitor webview screens are loaded on selecting tabs after the first time
  • Site monitor screens are not loaded in the first time
  1. What I did to test those areas of impact (or what existing automated tests I relied on)
    Manual testing

  2. What automated tests I added (or what prevented me from doing so)
    N/A

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

UI Changes testing checklist:

  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • Talkback.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • Large and small screen sizes. (Tablet and smaller phones)
  • Multi-tasking: Split screen and Pop-up view. (Android 10 or higher)

@AjeshRPai AjeshRPai linked an issue Jan 30, 2024 that may be closed by this pull request
@AjeshRPai AjeshRPai requested review from pantstamp and zwarm January 30, 2024 09:56
@dangermattic
Copy link
Collaborator

dangermattic commented Jan 30, 2024

1 Warning
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jan 30, 2024

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr20077-82d7b92
Commit82d7b92
Direct Downloadwordpress-prototype-build-pr20077-82d7b92.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jan 30, 2024

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr20077-82d7b92
Commit82d7b92
Direct Downloadjetpack-prototype-build-pr20077-82d7b92.apk
Note: Google Login is not supported on these builds.

@AjeshRPai AjeshRPai changed the title Fixes: site monitor prevent webview reload WIP Fixes: site monitor prevent webview reload Jan 30, 2024
@AjeshRPai AjeshRPai added this to the 24.2 milestone Jan 31, 2024
@AjeshRPai AjeshRPai marked this pull request as ready for review January 31, 2024 10:22
Copy link

codecov bot commented Jan 31, 2024

Codecov Report

Attention: 49 lines in your changes are missing coverage. Please review.

Comparison is base (69fe5f0) 40.16% compared to head (6a7a13d) 40.26%.
Report is 2 commits behind head on trunk.

❗ Current head 6a7a13d differs from pull request most recent head b697e79. Consider uploading reports for the commit b697e79 to get more accurate results

Files Patch % Lines
...droid/ui/sitemonitor/SiteMonitorParentViewModel.kt 0.00% 34 Missing ⚠️
...oid/ui/sitemonitor/SiteMonitorTabViewModelSlice.kt 0.00% 11 Missing ⚠️
...android/ui/sitemonitor/SiteMonitorWebViewClient.kt 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #20077      +/-   ##
==========================================
+ Coverage   40.16%   40.26%   +0.10%     
==========================================
  Files        1457     1455       -2     
  Lines       66980    66950      -30     
  Branches    11065    11051      -14     
==========================================
+ Hits        26904    26959      +55     
+ Misses      37587    37501      -86     
- Partials     2489     2490       +1     

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

webServerViewModel.start(SiteMonitorType.WEB_SERVER_LOGS, SiteMonitorTabItem.WebServerLogs.urlTemplate, site)
}

fun getUiState(siteMonitorType: SiteMonitorType): MutableState<SiteMonitorUiState> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to return here State instead of MutableState? I guess the consume is not going to modify the received state. WDYT @AjeshRPai ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch @pantstamp, You are right. Its better to return state here. Done in f6633cf

private val _uiState = MutableStateFlow<SiteMonitorUiState>(SiteMonitorUiState.Preparing)
val uiState: StateFlow<SiteMonitorUiState> = _uiState
private val _uiState = mutableStateOf<SiteMonitorUiState>(SiteMonitorUiState.Preparing)
val uiState = _uiState
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why we do not return here state instead of mutable state like this?
val uiState: State<SiteMonitorUiState> = _uiState

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right @pantstamp , I have updated the variable type as suggested in this commit fb3c6b9

@pantstamp
Copy link
Contributor

Great work @AjeshRPai ! I really like the fact that you got rid of the fragment. I will take a look at the glitch to see what I can find.

@pantstamp
Copy link
Contributor

@AjeshRPai the first time that we launch the site monitoring screen, I can see the Tracked: site_monitoring_screen_shown but not the Tracked: site_monitoring_tab_shown, Properties: {"tab":"metrics"} even though the metrics tab is shown.

Is this what we want? I think that we should track this event even the first time.

Copy link
Contributor

@zwarm zwarm left a comment

Choose a reason for hiding this comment

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

@AjeshRPai - Thanks for finding a solution to the reload issue. 👏
With the exception of the few comment @pantstamp left, I am ready to give this a 👍 . In addition, I added a fix for the glitch. Please let me know what you think.

@zwarm
Copy link
Contributor

zwarm commented Jan 31, 2024

@AjeshRPai the first time that we launch the site monitoring screen, I can see the Tracked: site_monitoring_screen_shown but not the Tracked: site_monitoring_tab_shown, Properties: {"tab":"metrics"} even though the metrics tab is shown.

Is this what we want? I think that we should track this event even the first time.

@AjeshRPai @pantstamp - 🤔 We already capture Tracked: more_menu_item_tapped, Properties: {"item":"site_monitoring"}, so let's make stick with including "tab" property whenever we track site_monitoring_tab_shown

@AjeshRPai AjeshRPai changed the title WIP Fixes: site monitor prevent webview reload Fixes: site monitor prevent webview reload Jan 31, 2024
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Jan 31, 2024

Warnings
⚠️ PR has more than 300 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS

@zwarm zwarm enabled auto-merge January 31, 2024 17:16
@zwarm zwarm merged commit aadadca into trunk Jan 31, 2024
19 of 20 checks passed
@zwarm zwarm deleted the issue/20067-site-monitor-prevent-webview-reload branch January 31, 2024 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Site Monitor: Prevent webview reload
5 participants