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

Makes "Enable Notifications for this session" respond to enabled value in pusher #7281

Merged
merged 51 commits into from Oct 12, 2022

Conversation

ericdecanini
Copy link
Contributor

@ericdecanini ericdecanini commented Oct 3, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Meets criteria:

  • the ‘notifications on this device’ toggle should check the pusher.enabled field and display as off when pusher.enabled is false
  • When there is a registered pusher with enabled: false - toggling on should set the enabled field to true on the existing pusher

(the other AC are already current behaviour)

Motivation and context

Epic: https://element-io.atlassian.net/browse/PSG-595
Closes https://element-io.atlassian.net/browse/PSG-785

Screenshots / GIFs

Tests

  • Disable pusher in device manager
  • Go to notification settings
  • See Enable Notifications for this session is unchecked
  • Check this setting
  • See pusher is now enabled

Tested devices

  • Physical
  • Emulator
  • OS version(s): Android 13

Checklist

@ericdecanini ericdecanini changed the base branch from develop to feature/eric/push-toggle-notifications October 3, 2022 23:43
@ericdecanini ericdecanini marked this pull request as ready for review October 3, 2022 23:44
@ericdecanini ericdecanini requested review from a team and mnaturel and removed request for a team October 3, 2022 23:45
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Just a small remark

@@ -117,6 +123,9 @@ class VectorSettingsNotificationPreferenceFragment :
}
findPreference<VectorPreference>(VectorPreferences.SETTINGS_NOTIFICATION_METHOD_KEY)
?.summary = unifiedPushHelper.getCurrentDistributorName()
lifecycleScope.launch {
pushersManager.togglePusherForCurrentSession(true)
Copy link
Member

Choose a reason for hiding this comment

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

You need a try catch, it will crash if there is for instance no network.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, ideally a runCatching may be added inside the PushersManager.togglePusherForCurrentSession() method. And failure may be prompted to the user.

coVerify(ordering = Ordering.ALL) {
getPushersLive() // verifies only getPushersLive and the following togglePusher was called
togglePusher(pusher, enable)
}
}

fun verifyOnlyGetPushersAndTogglePusherCalled(pusher: Pusher, enable: Boolean) {
coVerify(ordering = Ordering.ALL) {
getPushers() // verifies only getPushersLive and the following togglePusher was called
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment should be updated I guess by replacing getPushersLive() by getPushers(). Or comments in these methods could be removed.

Copy link
Contributor

@mnaturel mnaturel left a comment

Choose a reason for hiding this comment

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

Not tested but LGTM. Just added a minor comment.

…ifications

# Conflicts:
#	vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewAction.kt
#	vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt
#	vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModel.kt
#	vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewState.kt
#	vector/src/main/res/layout/fragment_session_overview.xml
#	vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModelTest.kt
…ic/notificaton-settings-enabled

# Conflicts:
#	vector/src/test/java/im/vector/app/core/pushers/PushersManagerTest.kt
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

SGTM, just a remark about the new string.

@@ -931,6 +931,7 @@
<string name="settings_call_notifications_preferences">Configure Call Notifications</string>
<string name="settings_silent_notifications_preferences">Configure Silent Notifications</string>
<string name="settings_system_preferences_summary">Choose LED color, vibration, sound…</string>
<string name="settings_error_toggle_pusher">Something went wrong. Please check your network connection and try again.</string>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe use a more generic key for this string, which could be re-use in other circumstances.
Something like error_check_network (we already have error_no_network)

@@ -206,110 +203,6 @@ class SessionOverviewViewModelTest {
.finish()
}

@Test
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 to having removed all tests on SignoutAction ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think they were lost during a merge conflict. Good catch

Copy link
Contributor

@mnaturel mnaturel left a comment

Choose a reason for hiding this comment

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

I think we need to cancel the removing of unit tests on SignoutAction in the `SessionOverviewViewModelTest.

Base automatically changed from feature/eric/push-toggle-notifications to develop October 10, 2022 23:21
…icaton-settings-enabled

# Conflicts:
#	vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModelTest.kt
#	vector/src/test/java/im/vector/app/test/fakes/FakePushersService.kt
Copy link
Contributor

@mnaturel mnaturel left a comment

Choose a reason for hiding this comment

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

I have seen 3 points to fix:

  • on UI side, there is an issue with the constraints in the session overview screen, see the capture below.
  • on UI side, when the push notifications are disabled when arriving into the session overview screen, we see the toggle is moving from enabled to disabled. I wonder if we could do something to avoid that?
  • on Realm database side: since we updated the PusherEntity, there should be a database migration and it looks like we don't have it yet (could be done in another PR I guess).

@ericdecanini
Copy link
Contributor Author

I have seen 3 points to fix:

  • on UI side, there is an issue with the constraints in the session overview screen, see the capture below.
  • on UI side, when the push notifications are disabled when arriving into the session overview screen, we see the toggle is moving from enabled to disabled. I wonder if we could do something to avoid that?
  • on Realm database side: since we updated the PusherEntity, there should be a database migration and it looks like we don't have it yet (could be done in another PR I guess).

All 3 points addressed

Copy link
Contributor

@mnaturel mnaturel left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes! I think the small animation of the switchButton is not fixed since it happens now when the push notifications are enabled. We can see going from disabled state to enabled state. But honestly, I don't know how we could fix it.

Copy link
Contributor

@mnaturel mnaturel left a comment

Choose a reason for hiding this comment

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

And other thing, could we bind the whole push notification view to change the toggle instead of only the switch? It will ease the toggling for the user.

There is also another problem with navigation to session details, it may have been deleted during merges. I created a fix PR for that: #7340

@mnaturel mnaturel added the Z-NextRelease For issues and PRs which should be included in the NextRelease. label Oct 12, 2022
Copy link
Contributor

@mnaturel mnaturel left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix on the switch.

@sonarcloud
Copy link

sonarcloud bot commented Oct 12, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

26.8% 26.8% Coverage
0.0% 0.0% Duplication

@ericdecanini ericdecanini merged commit 9857fa6 into develop Oct 12, 2022
@ericdecanini ericdecanini deleted the feature/eric/notificaton-settings-enabled branch October 12, 2022 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-NextRelease For issues and PRs which should be included in the NextRelease.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants