From 8073d6f3163995159319a0f4a8b0ad9cd32b087e Mon Sep 17 00:00:00 2001 From: Danh Date: Wed, 27 Sep 2023 17:58:35 +0700 Subject: [PATCH 1/4] fix: when asset too small --- .../NotificationCenter/KyberAIWatchlist.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/Announcement/PrivateAnnoucement/NotificationCenter/KyberAIWatchlist.tsx b/src/components/Announcement/PrivateAnnoucement/NotificationCenter/KyberAIWatchlist.tsx index a73cd70f13..c077f940ef 100644 --- a/src/components/Announcement/PrivateAnnoucement/NotificationCenter/KyberAIWatchlist.tsx +++ b/src/components/Announcement/PrivateAnnoucement/NotificationCenter/KyberAIWatchlist.tsx @@ -31,6 +31,8 @@ export default function AnnouncementItem({ const theme = useTheme() const navigate = useNavigate() const [expand, setExpand] = useState(false) + const slice = 3 + const minimalAssets = assets.slice(0, slice) return ( setExpand(!expand)}> @@ -49,10 +51,10 @@ export default function AnnouncementItem({ Here is an update on the tokens in your watchlist: {!expand && - assets.slice(0, 3).map((token, i) => ( + minimalAssets.map((token, i) => ( - {i === 2 ? ', ...' : ', '} + {i === minimalAssets.length - 1 ? (minimalAssets.length < slice ? '' : ', ...') : ', '} ))} From c5f55238f4572b71b460d825112b3e0435659bb9 Mon Sep 17 00:00:00 2001 From: Danh Date: Wed, 27 Sep 2023 18:00:08 +0700 Subject: [PATCH 2/4] add template type --- src/constants/env.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/constants/env.ts b/src/constants/env.ts index 378da69d50..db0db66751 100644 --- a/src/constants/env.ts +++ b/src/constants/env.ts @@ -113,13 +113,15 @@ export const FIREBASE: { [key: string]: { DEFAULT: FirebaseConfig; LIMIT_ORDER?: }, } -const ANNOUNCEMENT_TEMPLATE_IDS: { [key: string]: { [type: string]: string } } = { +// todo refaactor type check +const ANNOUNCEMENT_TEMPLATE_IDS: { [key in EnvKeys]: { [type: string]: string } } = { development: { [PrivateAnnouncementType.PRICE_ALERT]: '53', [PrivateAnnouncementType.LIMIT_ORDER]: '8,9,10,11,33,34,35,36', [PrivateAnnouncementType.BRIDGE_ASSET]: '37,38', [PrivateAnnouncementType.CROSS_CHAIN]: '48,49', [PrivateAnnouncementType.KYBER_AI]: '46', + [PrivateAnnouncementType.KYBER_AI_WATCHLIST]: '54', [PrivateAnnouncementType.ELASTIC_POOLS]: '39,40', EXCLUDE: '2,29,1,47,50,44,45', }, @@ -129,6 +131,7 @@ const ANNOUNCEMENT_TEMPLATE_IDS: { [key: string]: { [type: string]: string } } = [PrivateAnnouncementType.BRIDGE_ASSET]: '12,13', [PrivateAnnouncementType.CROSS_CHAIN]: '25,26', [PrivateAnnouncementType.KYBER_AI]: '27', + [PrivateAnnouncementType.KYBER_AI_WATCHLIST]: '54', // todo [PrivateAnnouncementType.ELASTIC_POOLS]: '20,21', EXCLUDE: '2,11,1,28,29,22,23', }, @@ -138,6 +141,7 @@ const ANNOUNCEMENT_TEMPLATE_IDS: { [key: string]: { [type: string]: string } } = [PrivateAnnouncementType.BRIDGE_ASSET]: '10,11', [PrivateAnnouncementType.CROSS_CHAIN]: '27,28', [PrivateAnnouncementType.KYBER_AI]: '26', + [PrivateAnnouncementType.KYBER_AI_WATCHLIST]: '54', // todo [PrivateAnnouncementType.ELASTIC_POOLS]: '17,18', EXCLUDE: '2,16,19,9,25,24,21,22', }, From efd19a0cbfb000e2a034c5142c8c18c60df87e78 Mon Sep 17 00:00:00 2001 From: Danh Date: Wed, 27 Sep 2023 23:03:09 +0700 Subject: [PATCH 3/4] refactor type --- src/constants/env.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/constants/env.ts b/src/constants/env.ts index db0db66751..1dcc6fa861 100644 --- a/src/constants/env.ts +++ b/src/constants/env.ts @@ -63,7 +63,7 @@ type FirebaseConfig = { measurementId?: string } -export const FIREBASE: { [key: string]: { DEFAULT: FirebaseConfig; LIMIT_ORDER?: FirebaseConfig } } = { +export const FIREBASE: { [key in EnvKeys]: { DEFAULT: FirebaseConfig; LIMIT_ORDER?: FirebaseConfig } } = { development: { LIMIT_ORDER: { apiKey: 'AIzaSyBHRrinrQ3CXVrevZN442fjG0EZ-nYNNaU', @@ -113,8 +113,8 @@ export const FIREBASE: { [key: string]: { DEFAULT: FirebaseConfig; LIMIT_ORDER?: }, } -// todo refaactor type check -const ANNOUNCEMENT_TEMPLATE_IDS: { [key in EnvKeys]: { [type: string]: string } } = { +type Config = { [type in PrivateAnnouncementType]: string } & { EXCLUDE: string } +const ANNOUNCEMENT_TEMPLATE_IDS: { [key in EnvKeys]: Config } = { development: { [PrivateAnnouncementType.PRICE_ALERT]: '53', [PrivateAnnouncementType.LIMIT_ORDER]: '8,9,10,11,33,34,35,36', @@ -123,6 +123,7 @@ const ANNOUNCEMENT_TEMPLATE_IDS: { [key in EnvKeys]: { [type: string]: string } [PrivateAnnouncementType.KYBER_AI]: '46', [PrivateAnnouncementType.KYBER_AI_WATCHLIST]: '54', [PrivateAnnouncementType.ELASTIC_POOLS]: '39,40', + [PrivateAnnouncementType.DIRECT_MESSAGE]: '', EXCLUDE: '2,29,1,47,50,44,45', }, staging: { @@ -133,6 +134,7 @@ const ANNOUNCEMENT_TEMPLATE_IDS: { [key in EnvKeys]: { [type: string]: string } [PrivateAnnouncementType.KYBER_AI]: '27', [PrivateAnnouncementType.KYBER_AI_WATCHLIST]: '54', // todo [PrivateAnnouncementType.ELASTIC_POOLS]: '20,21', + [PrivateAnnouncementType.DIRECT_MESSAGE]: '', EXCLUDE: '2,11,1,28,29,22,23', }, production: { @@ -143,6 +145,7 @@ const ANNOUNCEMENT_TEMPLATE_IDS: { [key in EnvKeys]: { [type: string]: string } [PrivateAnnouncementType.KYBER_AI]: '26', [PrivateAnnouncementType.KYBER_AI_WATCHLIST]: '54', // todo [PrivateAnnouncementType.ELASTIC_POOLS]: '17,18', + [PrivateAnnouncementType.DIRECT_MESSAGE]: '', EXCLUDE: '2,16,19,9,25,24,21,22', }, } From 0f75f8c28a513606da58bcf67e86ca8c5c3d5187 Mon Sep 17 00:00:00 2001 From: Danh Date: Thu, 28 Sep 2023 13:41:51 +0700 Subject: [PATCH 4/4] check for elastic pool --- src/hooks/useNotification/index.ts | 3 +++ src/pages/NotificationCenter/NotificationPreference/index.tsx | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hooks/useNotification/index.ts b/src/hooks/useNotification/index.ts index 214af53b4b..ceab132410 100644 --- a/src/hooks/useNotification/index.ts +++ b/src/hooks/useNotification/index.ts @@ -29,6 +29,7 @@ export type Topic = { type: TopicType isKyberAI: boolean isPriceAlert: boolean + isPriceElasticPool: boolean } type SaveNotificationParam = { @@ -58,8 +59,10 @@ const useNotification = () => { ...e, id: Date.now() + i, isSubscribed: e?.topics?.every(e => e.isSubscribed), + // special topic ids isKyberAI: e?.topics?.some(e => e.id + '' === KYBER_AI_TOPIC_ID), isPriceAlert: e?.topics?.some(e => e.id + '' === PRICE_ALERT_TOPIC_ID), + isPriceElasticPool: e?.topics?.some(e => e.id + '' === ELASTIC_POOL_TOPIC_ID), })) dispatch(setSubscribedNotificationTopic({ topicGroups })) }, [resp, dispatch]) diff --git a/src/pages/NotificationCenter/NotificationPreference/index.tsx b/src/pages/NotificationCenter/NotificationPreference/index.tsx index 709401816a..7973b1137f 100644 --- a/src/pages/NotificationCenter/NotificationPreference/index.tsx +++ b/src/pages/NotificationCenter/NotificationPreference/index.tsx @@ -11,6 +11,7 @@ import Loader from 'components/Loader' import Row from 'components/Row' import { MouseoverTooltip } from 'components/Tooltip' import { PRICE_ALERT_TOPIC_ID } from 'constants/env' +import { useActiveWeb3React } from 'hooks' import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel' import useNotification, { Topic, TopicType } from 'hooks/useNotification' import useTheme from 'hooks/useTheme' @@ -141,6 +142,7 @@ function NotificationPreference({ toggleModal = noop }: { toggleModal?: () => vo const theme = useTheme() const { isLoading, saveNotification, topicGroups: topicGroupsGlobal, unsubscribeAll } = useNotification() + const { account } = useActiveWeb3React() const { userInfo, isLogin } = useSessionInfo() const { isSignInEmail } = useSignedAccountInfo() const { isWhiteList } = useIsWhiteListKyberAI() @@ -386,7 +388,7 @@ function NotificationPreference({ toggleModal = noop }: { toggleModal?: () => vo {commons.map(topic => { - const isDisabled = topic.isPriceAlert ? false : disableCheckbox + const isDisabled = topic.isPriceElasticPool ? !account : topic.isPriceAlert ? false : disableCheckbox return renderTopic( topic, isDisabled,