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

feat: Update the counter over the fox to handle notifications #25093

Merged
merged 15 commits into from
Jun 18, 2024

Conversation

matteoscurati
Copy link
Contributor

@matteoscurati matteoscurati commented Jun 6, 2024

Description

This PR introduces a new type of counter over the Fox icon to display the number of unread notifications within the extension. This new counter interacts with the existing counter for unapproved transactions in the following way:

  • If there are unapproved transactions, a blue badge with a label containing three dots is displayed
  • If there are unread notifications, a red badge with a label containing the number of unread notifications is displayed. If there are more than 10 notifications, the label shows "9+"

The two badges are not shown together, and the badge for unapproved transactions takes priority over the badge for unread notifications.

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

In the video, I demonstrate how to test this new feature.

Screenshots/Recordings

https://www.loom.com/share/9a32ec2bd02447e8a29adc4ac1cd3522?sid=d1f74163-54f0-4513-948c-1faa158bd601

Before

After

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've completed the PR template to the best of my ability
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.

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 Jun 6, 2024
@matteoscurati matteoscurati marked this pull request as ready for review June 6, 2024 10:31
@matteoscurati matteoscurati requested review from a team as code owners June 6, 2024 10:31
Copy link
Contributor

github-actions bot commented Jun 6, 2024

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.

Copy link

codecov bot commented Jun 6, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 65.40%. Comparing base (ed06176) to head (2d8d36a).
Report is 1 commits behind head on develop.

Files Patch % Lines
...s/metamask-notifications/metamask-notifications.ts 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #25093      +/-   ##
===========================================
- Coverage    65.42%   65.40%   -0.01%     
===========================================
  Files         1380     1380              
  Lines        54688    54715      +27     
  Branches     14339    14348       +9     
===========================================
+ Hits         35776    35786      +10     
- Misses       18912    18929      +17     

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

Copy link
Contributor

@Prithpal-Sooriya Prithpal-Sooriya left a comment

Choose a reason for hiding this comment

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

Looks good. I have 1 comment on badge counter try/catch part (since I'm paranoid)

@metamaskbot
Copy link
Collaborator

Builds ready [2f4d365]
Page Load Metrics (243 ± 259 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint791129595
domContentLoaded10191221
load501862243540259
domInteractive10191221
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.68 KiB (0.05%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

app/scripts/background.js Show resolved Hide resolved
app/scripts/background.js Outdated Show resolved Hide resolved
app/scripts/background.js Outdated Show resolved Hide resolved
app/scripts/background.js Outdated Show resolved Hide resolved
app/scripts/background.js Outdated Show resolved Hide resolved
app/scripts/background.js Show resolved Hide resolved
Comment on lines 85 to 90
// eslint-disable-next-line @metamask/design-tokens/color-no-hex
const BADGE_COLOR_APPROVAL = '#0376C9';
// eslint-disable-next-line @metamask/design-tokens/color-no-hex
const BADGE_COLOR_NOTIFICATION = '#D73847';
const BADGE_LABEL_APPROVAL = '\u22EF'; // unicode ellipsis
const BADGE_MAX_NOTIFICATION_COUNT = '9';
Copy link
Contributor

Choose a reason for hiding this comment

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

These are nice constants!

label = BADGE_LABEL_APPROVAL;
} else if (unreadNotificationsCount > 0) {
label =
unreadNotificationsCount > BADGE_MAX_NOTIFICATION_COUNT
Copy link
Contributor

Choose a reason for hiding this comment

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

BADGE_MAX_NOTIFICATION_COUNT seems to be a string, seems a little odd to do string greater than here.

JS probably converts this to a number when doing this check.

Instead change BADGE_MAX_NOTIFICATION_COUNT to a number for valid conditional.

Copy link
Contributor

@Prithpal-Sooriya Prithpal-Sooriya Jun 7, 2024

Choose a reason for hiding this comment

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

(Prith note, this is just me rambling to myself) why don't we use // @ts-check in our JS files? I guess this will force JS files to be passed through our compiler and might give us false sense of security (since not true TS)... but I think it would still be handy to prevent type mismatch.

@metamaskbot
Copy link
Collaborator

Builds ready [843a2d5]
Page Load Metrics (51 ± 3 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint70958273
domContentLoaded9201121
load42755173
domInteractive9201121
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.87 KiB (0.05%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

matthewwalsh0
matthewwalsh0 previously approved these changes Jun 10, 2024
app/scripts/background.js Outdated Show resolved Hide resolved
@metamaskbot
Copy link
Collaborator

Builds ready [7e13ad5]
Page Load Metrics (51 ± 8 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint6316485199
domContentLoaded9201121
load4211851168
domInteractive9201121
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.87 KiB (0.05%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [2d8d36a]
Page Load Metrics (40 ± 1 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint57897174
domContentLoaded810910
load38454021
domInteractive810910
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.86 KiB (0.05%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@matteoscurati matteoscurati merged commit cab9dba into develop Jun 18, 2024
74 checks passed
@matteoscurati matteoscurati deleted the feat/new-counter-over-the-fox branch June 18, 2024 12:14
@github-actions github-actions bot locked and limited conversation to collaborators Jun 18, 2024
@metamaskbot metamaskbot added the release-12.1.0 Issue or pull request that will be included in release 12.1.0 label Jun 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.1.0 Issue or pull request that will be included in release 12.1.0 team-notifications Notifications team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants