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

fix: disable notifications when basic functionality off #28045

Merged
merged 11 commits into from
Oct 24, 2024

Conversation

matteoscurati
Copy link
Contributor

@matteoscurati matteoscurati commented Oct 23, 2024

Description

This PR ensures that notifications are correctly disabled when the user deactivates Basic functionality. The current implementation only disables profile sync when Basic functionality is turned off, leaving notifications in an incorrect state—they can’t be fetched but remain active. This causes a series of UI errors, the most obvious being that the counters stay visible.

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. With notifications active
  2. Deactivate Basic functionality
  3. Verify that notifications cannot be enabled unless Basic functionality is reactivated
  4. Verify that the counter no longer shows any unread notifications

Screenshots/Recordings

Before

Screenshot 2024-10-24 at 10 08 32

After

Screenshot 2024-10-24 at 10 19 48

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@matteoscurati matteoscurati added the team-notifications Notifications team label Oct 23, 2024
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@@ -83,6 +85,9 @@ export function useDisableProfileSyncing(): {
try {
// disable profile syncing
await dispatch(disableProfileSyncingAction());

// list notifications to update the counter
await listNotifications();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updating the list after the notifications have been disabled, the counter is set to zero

Copy link
Contributor

Choose a reason for hiding this comment

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

nice, we can ticket this for a core change in future.

@@ -74,15 +74,14 @@ export function NotificationsSettingsAllowNotifications({
}, [isMetamaskNotificationsEnabled]);

useEffect(() => {
if (isMetamaskNotificationsEnabled && !error) {
if (!error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this way, the update of the list and therefore the counter is triggered even when the notifications are disabled

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to update the list when the notifications are enabled AND disabled (because we want to reset the counter)

FUTURE - move logic to core library instead of doing this error/reset.

@matteoscurati matteoscurati changed the title Fix: disable notifications when basic functionality off fix: disable notifications when basic functionality off Oct 24, 2024
@matteoscurati matteoscurati marked this pull request as ready for review October 24, 2024 08:31
@matteoscurati matteoscurati requested review from a team as code owners October 24, 2024 08:31
@@ -31,14 +30,14 @@ import { getUseExternalServices } from '../../../../selectors';

function ProfileSyncBasicFunctionalitySetting() {
const basicFunctionality: boolean = useSelector(getUseExternalServices);
const { setIsProfileSyncingEnabled } = useSetIsProfileSyncingEnabled();
const { disableProfileSyncing } = useDisableProfileSyncing();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, this hook will disable profile syncing and disable notifications.

FUTURE - we probs want to clean up the hooks.

@metamaskbot
Copy link
Collaborator

Builds ready [6a5814f]
Page Load Metrics (2071 ± 109 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint176128842074229110
domContentLoaded174928272042217104
load176028832071227109
domInteractive26177583617
backgroundConnect1076322412
firstReactRender5013299209
getState765252211
initialActions01000
loadScripts12732268152119995
setupStore1279292411
uiStartup196731172294227109
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 274 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@matteoscurati matteoscurati added this pull request to the merge queue Oct 24, 2024
Merged via the queue into develop with commit f0aad1c Oct 24, 2024
76 checks passed
@matteoscurati matteoscurati deleted the fix/basic-functionality-disable-notifications branch October 24, 2024 14:31
@github-actions github-actions bot locked and limited conversation to collaborators Oct 24, 2024
@metamaskbot metamaskbot added the release-12.7.0 Issue or pull request that will be included in release 12.7.0 label Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.7.0 Issue or pull request that will be included in release 12.7.0 team-notifications Notifications team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants