Skip to content

Commit

Permalink
fix: Avoid trying to show non mapped notifications (#191)
Browse files Browse the repository at this point in the history
* fix: Avoid trying to show non mapped notifications

* chore(deps): bump schemas
  • Loading branch information
kevinszuchet authored Sep 5, 2024
1 parent 701d3e9 commit 9c8e91a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"homepage": "https://github.com/decentraland/ui2#readme",
"dependencies": {
"@dcl/schemas": "^13.8.6",
"@dcl/schemas": "^13.9.0",
"@dcl/ui-env": "^1.5.1",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
Expand Down
17 changes: 10 additions & 7 deletions src/components/Notifications/NotificationsFeedTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ const NotificationHandler = ({
renderProfile?: (address: string) => JSX.Element | string | null
}) => {
const NotificationComponent = NotificationComponentByType[notification.type]

if (!NotificationComponent) {
return null
}

return (
NotificationComponent && (
<NotificationComponent
notification={notification}
locale={locale}
renderProfile={renderProfile}
/>
)
<NotificationComponent
notification={notification}
locale={locale}
renderProfile={renderProfile}
/>
)
}

Expand Down
8 changes: 2 additions & 6 deletions src/components/Notifications/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ function getBGColorByRarity(rarity: Rarity) {
return Rarity.getGradient(rarity).join()
}

type DecentralandNotificationComponentByType<T> = {
type DecentralandNotificationComponentByType<T> = Partial<{
[k in NotificationType]: T extends DCLNotificationProps
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
FunctionComponent<CommonNotificationProps<any>> | null
: never
}
}>

const NotificationComponentByType: DecentralandNotificationComponentByType<DCLNotificationProps> =
{
Expand Down Expand Up @@ -92,10 +92,6 @@ const NotificationComponentByType: DecentralandNotificationComponentByType<DCLNo
WorldsPermissionGrantedNotification,
[NotificationType.WORLDS_PERMISSION_REVOKED]:
WorldsPermissionRevokedNotification,
[NotificationType.BADGE_GRANTED]: null,
[NotificationType.GOVERNANCE_CLIFF_ENDED]: null,
[NotificationType.GOVERNANCE_WHALE_VOTE]: null,
[NotificationType.GOVERNANCE_VOTED_ON_BEHALF]: null,
[NotificationType.REWARD_CAMPAIGN_OUT_OF_FUNDS]:
CampaignOutOfFundsNotification,
[NotificationType.REWARD_CAMPAIGN_GAS_PRICE_HIGHER_THAN_EXPECTED]:
Expand Down

0 comments on commit 9c8e91a

Please sign in to comment.