Skip to content

Commit

Permalink
Merge branch 'inbox-watchlist' into kyberai-filter-sort
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhoaidanh committed Sep 28, 2023
2 parents 643c92f + 0f75f8c commit 8fd4ff7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Wrapper onClick={() => setExpand(!expand)}>
Expand All @@ -49,10 +51,10 @@ export default function AnnouncementItem({
<Desc style={{ gap: 6, flexWrap: 'wrap', color: theme.subText }}>
<Trans>Here is an update on the tokens in your watchlist:</Trans>
{!expand &&
assets.slice(0, 3).map((token, i) => (
minimalAssets.map((token, i) => (
<Fragment key={i}>
<TokenInfo token={token} showPrice={false} key={i} logoSize={'14px'} />
{i === 2 ? ', ...' : ', '}
{i === minimalAssets.length - 1 ? (minimalAssets.length < slice ? '' : ', ...') : ', '}
</Fragment>
))}
</Desc>
Expand Down
11 changes: 9 additions & 2 deletions src/constants/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -113,14 +113,17 @@ export const FIREBASE: { [key: string]: { DEFAULT: FirebaseConfig; LIMIT_ORDER?:
},
}

const ANNOUNCEMENT_TEMPLATE_IDS: { [key: string]: { [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',
[PrivateAnnouncementType.BRIDGE_ASSET]: '37,38',
[PrivateAnnouncementType.CROSS_CHAIN]: '48,49',
[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: {
Expand All @@ -129,7 +132,9 @@ 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',
[PrivateAnnouncementType.DIRECT_MESSAGE]: '',
EXCLUDE: '2,11,1,28,29,22,23',
},
production: {
Expand All @@ -138,7 +143,9 @@ 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',
[PrivateAnnouncementType.DIRECT_MESSAGE]: '',
EXCLUDE: '2,16,19,9,25,24,21,22',
},
}
Expand Down
3 changes: 3 additions & 0 deletions src/hooks/useNotification/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export type Topic = {
type: TopicType
isKyberAI: boolean
isPriceAlert: boolean
isPriceElasticPool: boolean
}

type SaveNotificationParam = {
Expand Down Expand Up @@ -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])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -386,7 +388,7 @@ function NotificationPreference({ toggleModal = noop }: { toggleModal?: () => vo
<ListGroupWrapper>
<GroupColum>
{commons.map(topic => {
const isDisabled = topic.isPriceAlert ? false : disableCheckbox
const isDisabled = topic.isPriceElasticPool ? !account : topic.isPriceAlert ? false : disableCheckbox
return renderTopic(
topic,
isDisabled,
Expand Down

0 comments on commit 8fd4ff7

Please sign in to comment.