-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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: Notifications platform links #24708
Conversation
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. |
app/scripts/controllers/metamask-notifications/services/feature-announcements.ts
Show resolved
Hide resolved
@@ -67,7 +69,12 @@ export async function onNotificationClick(event: NotificationEvent) { | |||
const data: OnChainRawNotification = event?.notification?.data; | |||
|
|||
// Navigate | |||
const destination = `chrome-extension://${sw.location.host}/home.html#notifications/${data.id}`; | |||
const getPlatformResult = getPlatform(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double check this getPlatform
code.
This calls window.navigator
, and the window
does not exist on service workers.
We might want to replace this with global.navigator
or self.navigator
@danjm is this function getPlatform
used in other controllers? We are not seeing any regressions or errors using this? If it works, then feel free to keep using it @matteoscurati .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Prithpal-Sooriya everything seems to be working correctly. I tried generating the links by also printing the different steps and everything seems to work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of this: https://github.com/MetaMask/metamask-extension/blob/develop/app/scripts/init-globals.js#L17
window
, in our app/
code under mv3, refers to the ServiceWorkerGlobalScope
and not an actual window
. The ServiceWorkerGlobalScope
has some, but not all, of the apis an actual window
has. navigator
is one of the APIs it does have, so this should be fine
ui/pages/notifications/notification-components/erc1155-sent-received/erc1155-sent-received.tsx
Outdated
Show resolved
Hide resolved
The base branch was changed.
2b6e4ac
to
4fe125f
Compare
Builds ready [5ac245e]
Page Load Metrics (1316 ± 596 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
||
const blockExplorerUrl = | ||
defaultNetwork?.rpcPrefs?.blockExplorerUrl ?? | ||
defaultNetwork?.rpcUrl ?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think ?? defaultNetwork?.rpcUrl
should be here, as rpcUrl
should never be a block explorer url
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danjm you’re right. This is the type:
export type NetworkConfiguration = {
rpcUrl: string;
chainId: Hex;
ticker: string;
nickname?: string;
rpcPrefs?: {
blockExplorerUrl: string;
};
};
I removed defaultNetwork?.rpcUrl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more comment from me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok LGTM. We will get another Notification dev to review. This was previously approved by Dan too.
Missing release label release-12.0.0 on PR. Adding release label release-12.0.0 on PR and removing other release labels(release-12.1.0), as PR was cherry-picked in branch 12.0.0. |
Description
This PR introduces the logic to handle links within notifications to support the different platforms on which we can use the extension.
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist