From fad8d7e4d91b5c734bbab5502bf5869a8d6f8ec1 Mon Sep 17 00:00:00 2001 From: Kevin Szuchet <31735779+kevinszuchet@users.noreply.github.com> Date: Thu, 5 Sep 2024 17:10:22 +0100 Subject: [PATCH 1/2] fix: Check if the notification has a mapped component (#560) * fix: Check if the notification has a mapped component * chore: Bump schemas --- package-lock.json | 38 +++++++++---------- package.json | 2 +- .../Notifications/NotificationsFeed.tsx | 5 +++ src/components/Notifications/utils.tsx | 15 ++++---- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/package-lock.json b/package-lock.json index 795ea427..258b328c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.0-development", "license": "MIT", "dependencies": { - "@dcl/schemas": "^13.6.2", + "@dcl/schemas": "^13.9.0", "@dcl/ui-env": "^1.5.1", "balloon-css": "^0.5.0", "classnames": "^2.3.2", @@ -2076,9 +2076,9 @@ } }, "node_modules/@dcl/schemas": { - "version": "13.8.5", - "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-13.8.5.tgz", - "integrity": "sha512-SO0pHJi3xfjwMMbVVLsXm/qrt1L7VCO09MA+eefsGPmfbboiUIBM2mxJFBMxrCn/F/+SSxI3uLHo8xytCjFdkg==", + "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", @@ -34322,7 +34322,7 @@ }, "node_modules/npm/node_modules/lodash._baseindexof": { "version": "3.1.0", - "extraneous": true, + "dev": true, "inBundle": true, "license": "MIT" }, @@ -34338,19 +34338,19 @@ }, "node_modules/npm/node_modules/lodash._bindcallback": { "version": "3.0.1", - "extraneous": true, + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/lodash._cacheindexof": { "version": "3.0.2", - "extraneous": true, + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/lodash._createcache": { "version": "3.1.2", - "extraneous": true, + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -34365,7 +34365,7 @@ }, "node_modules/npm/node_modules/lodash._getnative": { "version": "3.9.1", - "extraneous": true, + "dev": true, "inBundle": true, "license": "MIT" }, @@ -34383,7 +34383,7 @@ }, "node_modules/npm/node_modules/lodash.restparam": { "version": "3.6.1", - "extraneous": true, + "dev": true, "inBundle": true, "license": "MIT" }, @@ -49159,9 +49159,9 @@ } }, "@dcl/schemas": { - "version": "13.8.5", - "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-13.8.5.tgz", - "integrity": "sha512-SO0pHJi3xfjwMMbVVLsXm/qrt1L7VCO09MA+eefsGPmfbboiUIBM2mxJFBMxrCn/F/+SSxI3uLHo8xytCjFdkg==", + "version": "13.9.0", + "resolved": "https://registry.npmjs.org/@dcl/schemas/-/schemas-13.9.0.tgz", + "integrity": "sha512-t8t043TfxIpXqzR1mNehD4d6YFfbauq5ICoLL2Y72emSiu8q0bCI3pNCoaN0Ea6s7n+6AVv39Q8TvzWUneRBpQ==", "requires": { "ajv": "^8.11.0", "ajv-errors": "^3.0.0", @@ -73555,7 +73555,7 @@ "lodash._baseindexof": { "version": "3.1.0", "bundled": true, - "extraneous": true + "dev": true }, "lodash._baseuniq": { "version": "4.6.0", @@ -73569,17 +73569,17 @@ "lodash._bindcallback": { "version": "3.0.1", "bundled": true, - "extraneous": true + "dev": true }, "lodash._cacheindexof": { "version": "3.0.2", "bundled": true, - "extraneous": true + "dev": true }, "lodash._createcache": { "version": "3.1.2", "bundled": true, - "extraneous": true, + "dev": true, "requires": { "lodash._getnative": "^3.0.0" } @@ -73592,7 +73592,7 @@ "lodash._getnative": { "version": "3.9.1", "bundled": true, - "extraneous": true + "dev": true }, "lodash._root": { "version": "3.0.1", @@ -73607,7 +73607,7 @@ "lodash.restparam": { "version": "3.6.1", "bundled": true, - "extraneous": true + "dev": true }, "lodash.union": { "version": "4.6.0", diff --git a/package.json b/package.json index e7f7eab7..3c9f2a47 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "webpack-cli": "^3.3.2" }, "dependencies": { - "@dcl/schemas": "^13.6.2", + "@dcl/schemas": "^13.9.0", "@dcl/ui-env": "^1.5.1", "balloon-css": "^0.5.0", "classnames": "^2.3.2", diff --git a/src/components/Notifications/NotificationsFeed.tsx b/src/components/Notifications/NotificationsFeed.tsx index 1f2b351b..e60f09f3 100644 --- a/src/components/Notifications/NotificationsFeed.tsx +++ b/src/components/Notifications/NotificationsFeed.tsx @@ -121,6 +121,11 @@ const NotificationHandler = ({ renderProfile?: (address: string) => JSX.Element | string | null }) => { const NotificationComponent = NotificationComponentByType[notification.type] + + if (!NotificationComponent) { + return null + } + return ( = { - [k in NotificationType]: T extends DCLNotification - ? // eslint-disable-next-line @typescript-eslint/no-explicit-any - FunctionComponent> - : never -} +export type DecentralandNotificationComponentByType = Partial< + { + [k in NotificationType]: T extends DCLNotification + ? // eslint-disable-next-line @typescript-eslint/no-explicit-any + FunctionComponent> + : never + } +> export const NotificationComponentByType: DecentralandNotificationComponentByType = { @@ -101,7 +103,6 @@ export const NotificationComponentByType: DecentralandNotificationComponentByTyp CampaignOutOfStockNotification, [NotificationType.REWARD_CAMPAIGN_GAS_PRICE_HIGHER_THAN_EXPECTED]: CampaignGasPriceHigherThanExpectedNotification, - [NotificationType.BADGE_GRANTED]: null, [NotificationType.EVENTS_STARTS_SOON]: EventsStartsSoonNotification, [NotificationType.EVENTS_STARTED]: EventsStartedNotification, [NotificationType.WORLDS_PERMISSION_GRANTED]: From 93245014a1afc1a0042fdc26395e6bbb6f01023d Mon Sep 17 00:00:00 2001 From: Kevin Szuchet <31735779+kevinszuchet@users.noreply.github.com> Date: Thu, 5 Sep 2024 20:05:05 +0100 Subject: [PATCH 2/2] fix: Use the keys of the map as the CURRENT_AVAILABLE_NOTIFICATIONS (#561) --- src/components/Notifications/utils.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Notifications/utils.tsx b/src/components/Notifications/utils.tsx index d8f38f2d..ba1cd894 100644 --- a/src/components/Notifications/utils.tsx +++ b/src/components/Notifications/utils.tsx @@ -111,7 +111,9 @@ export const NotificationComponentByType: DecentralandNotificationComponentByTyp WorldsPermissionRevokedNotification } -export const CURRENT_AVAILABLE_NOTIFICATIONS = Object.values(NotificationType) +export const CURRENT_AVAILABLE_NOTIFICATIONS = Object.keys( + NotificationComponentByType +) export const replaceWithValues = ( str: string,