From 9c8e91a4611610e86738a6a89cccda08b308b98a Mon Sep 17 00:00:00 2001
From: Kevin Szuchet <31735779+kevinszuchet@users.noreply.github.com>
Date: Thu, 5 Sep 2024 17:13:28 +0100
Subject: [PATCH] fix: Avoid trying to show non mapped notifications (#191)
* fix: Avoid trying to show non mapped notifications
* chore(deps): bump schemas
---
package-lock.json | 8 ++++----
package.json | 2 +-
.../Notifications/NotificationsFeedTabs.tsx | 17 ++++++++++-------
src/components/Notifications/utils.tsx | 8 ++------
4 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 7407433..4b8aec1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,7 +9,7 @@
"version": "0.0.0-development",
"license": "Apache-2.0",
"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",
@@ -2312,9 +2312,9 @@
}
},
"node_modules/@dcl/schemas": {
- "version": "13.8.6",
- "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-13.8.6.tgz",
- "integrity": "sha512-n79qq6vT+95CY+o3wDroQ97q2vFuIRDKPcJI9S+RVOg9PyVYs8Z4bsHp6kqP2FhhscNLc85xEnIdD2/3SIh56A==",
+ "version": "13.9.0",
+ "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-13.9.0.tgz",
+ "integrity": "sha512-t8t043TfxIpXqzR1mNehD4d6YFfbauq5ICoLL2Y72emSiu8q0bCI3pNCoaN0Ea6s7n+6AVv39Q8TvzWUneRBpQ==",
"dependencies": {
"ajv": "^8.11.0",
"ajv-errors": "^3.0.0",
diff --git a/package.json b/package.json
index 9670df4..cc84d04 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/src/components/Notifications/NotificationsFeedTabs.tsx b/src/components/Notifications/NotificationsFeedTabs.tsx
index 51df827..aafed39 100644
--- a/src/components/Notifications/NotificationsFeedTabs.tsx
+++ b/src/components/Notifications/NotificationsFeedTabs.tsx
@@ -34,14 +34,17 @@ const NotificationHandler = ({
renderProfile?: (address: string) => JSX.Element | string | null
}) => {
const NotificationComponent = NotificationComponentByType[notification.type]
+
+ if (!NotificationComponent) {
+ return null
+ }
+
return (
- NotificationComponent && (
-
- )
+
)
}
diff --git a/src/components/Notifications/utils.tsx b/src/components/Notifications/utils.tsx
index 80d4afc..ad2420f 100644
--- a/src/components/Notifications/utils.tsx
+++ b/src/components/Notifications/utils.tsx
@@ -45,12 +45,12 @@ function getBGColorByRarity(rarity: Rarity) {
return Rarity.getGradient(rarity).join()
}
-type DecentralandNotificationComponentByType = {
+type DecentralandNotificationComponentByType = Partial<{
[k in NotificationType]: T extends DCLNotificationProps
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
FunctionComponent> | null
: never
-}
+}>
const NotificationComponentByType: DecentralandNotificationComponentByType =
{
@@ -92,10 +92,6 @@ const NotificationComponentByType: DecentralandNotificationComponentByType