Skip to content

Commit

Permalink
fix(notifications): fix toasts timeout, add config values (#313)
Browse files Browse the repository at this point in the history
Co-authored-by: Overzunov <[email protected]>
  • Loading branch information
VERZUOL1 and Overzunov authored Dec 27, 2021
1 parent a78dfa5 commit 032d83b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ NEXT_PUBLIC_AWS_IDENTITY_POOL_ID=eu-central-1:5887fd21-7b40-4871-a6cb-21097fe079
NEXT_PUBLIC_GOOGLE_ANALYTICS_KEY=GTM-TRCM9H7
NEXT_PUBLIC_RELEASE_NOTES=https://github.com/near-daos/astro-ui/releases/latest
NEXT_PUBLIC_I18_RELOAD_ON_PRERENDER=false
NEXT_PUBLIC_STATS_API_URL=https://mainnet.api.daostats.io
NEXT_PUBLIC_STATS_API_URL=https://mainnet.api.daostats.io
NEXT_PUBLIC_TOASTS_NOTIFICATIONS_TIMEOUT=20000
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NEXT_PUBLIC_API_URL=https://api.dev.app.astrodao.com
NEXT_PUBLIC_LOCAL_WALLET_REDIRECT=true
NEXT_PUBLIC_I18_RELOAD_ON_PRERENDER=true
NEXT_PUBLIC_STATS_API_URL=https://testnet.development.api.daostats.io
NEXT_PUBLIC_STATS_API_URL=https://testnet.development.api.daostats.io
NEXT_PUBLIC_TOASTS_NOTIFICATIONS_TIMEOUT=20000
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { FC, useCallback, useEffect, useRef, useState } from 'react';
import { AnimatePresence, motion } from 'framer-motion';
import uniqBy from 'lodash/uniqBy';
import { appConfig } from 'config';
import { useSwipeable } from 'react-swipeable';

import { useSocket } from 'context/SocketContext';
Expand Down Expand Up @@ -40,7 +41,12 @@ export const NotificationsToastsContainer: FC = () => {
noties.current = noties.current.filter(noty => {
const { timestamp } = noty;

return new Date().getTime() - timestamp < 2000000;
return (
new Date().getTime() - timestamp <
(appConfig.toastsNotificationsTimeout
? Number(appConfig.toastsNotificationsTimeout)
: 20000)
);
});
setNotifications(
noties.current
Expand Down
2 changes: 2 additions & 0 deletions config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ export const appConfig = {
),
statsApiUrl: `${process.env.NEXT_PUBLIC_STATS_API_URL}/api/v1/`,
socketUrl: process.env.NEXT_PUBLIC_API_URL,
toastsNotificationsTimeout:
process.env.NEXT_PUBLIC_TOASTS_NOTIFICATIONS_TIMEOUT,
};

0 comments on commit 032d83b

Please sign in to comment.