Commit 1a5f0e63 authored by Igor Stuev's avatar Igor Stuev Committed by GitHub

Change txs socket alert text (#2822)

parent a2b9c418
...@@ -33,7 +33,7 @@ interface Props { ...@@ -33,7 +33,7 @@ interface Props {
} }
const AddressBlocksValidated = ({ shouldRender = true, isQueryEnabled = true }: Props) => { const AddressBlocksValidated = ({ shouldRender = true, isQueryEnabled = true }: Props) => {
const [ socketAlert, setSocketAlert ] = React.useState(''); const [ showSocketAlert, setShowSocketAlert ] = React.useState(false);
const [ newItemsCount, setNewItemsCount ] = React.useState(0); const [ newItemsCount, setNewItemsCount ] = React.useState(0);
const queryClient = useQueryClient(); const queryClient = useQueryClient();
...@@ -60,11 +60,11 @@ const AddressBlocksValidated = ({ shouldRender = true, isQueryEnabled = true }: ...@@ -60,11 +60,11 @@ const AddressBlocksValidated = ({ shouldRender = true, isQueryEnabled = true }:
}); });
const handleSocketError = React.useCallback(() => { const handleSocketError = React.useCallback(() => {
setSocketAlert('An error has occurred while fetching new blocks. Please refresh the page to load new blocks.'); setShowSocketAlert(true);
}, []); }, []);
const handleNewSocketMessage: SocketMessage.NewBlock['handler'] = React.useCallback((payload) => { const handleNewSocketMessage: SocketMessage.NewBlock['handler'] = React.useCallback((payload) => {
setSocketAlert(''); setShowSocketAlert(false);
queryClient.setQueryData( queryClient.setQueryData(
getResourceKey('general:address_blocks_validated', { pathParams: { hash: addressHash } }), getResourceKey('general:address_blocks_validated', { pathParams: { hash: addressHash } }),
...@@ -121,7 +121,7 @@ const AddressBlocksValidated = ({ shouldRender = true, isQueryEnabled = true }: ...@@ -121,7 +121,7 @@ const AddressBlocksValidated = ({ shouldRender = true, isQueryEnabled = true }:
<TableBody> <TableBody>
<SocketNewItemsNotice.Desktop <SocketNewItemsNotice.Desktop
num={ newItemsCount } num={ newItemsCount }
alert={ socketAlert } showErrorAlert={ showSocketAlert }
type="block" type="block"
isLoading={ query.isPlaceholderData } isLoading={ query.isPlaceholderData }
/> />
...@@ -140,7 +140,7 @@ const AddressBlocksValidated = ({ shouldRender = true, isQueryEnabled = true }: ...@@ -140,7 +140,7 @@ const AddressBlocksValidated = ({ shouldRender = true, isQueryEnabled = true }:
{ query.pagination.page === 1 && ( { query.pagination.page === 1 && (
<SocketNewItemsNotice.Mobile <SocketNewItemsNotice.Mobile
num={ newItemsCount } num={ newItemsCount }
alert={ socketAlert } showErrorAlert={ showSocketAlert }
type="block" type="block"
isLoading={ query.isPlaceholderData } isLoading={ query.isPlaceholderData }
/> />
......
...@@ -73,7 +73,7 @@ const AddressTokenTransfers = ({ overloadCount = OVERLOAD_COUNT, shouldRender = ...@@ -73,7 +73,7 @@ const AddressTokenTransfers = ({ overloadCount = OVERLOAD_COUNT, shouldRender =
const currentAddress = getQueryParamString(router.query.hash); const currentAddress = getQueryParamString(router.query.hash);
const [ socketAlert, setSocketAlert ] = React.useState(''); const [ showSocketAlert, setShowSocketAlert ] = React.useState(false);
const [ newItemsCount, setNewItemsCount ] = React.useState(0); const [ newItemsCount, setNewItemsCount ] = React.useState(0);
const [ filters, setFilters ] = React.useState<Filters>( const [ filters, setFilters ] = React.useState<Filters>(
...@@ -109,7 +109,7 @@ const AddressTokenTransfers = ({ overloadCount = OVERLOAD_COUNT, shouldRender = ...@@ -109,7 +109,7 @@ const AddressTokenTransfers = ({ overloadCount = OVERLOAD_COUNT, shouldRender =
}, [ filters, onFilterChange ]); }, [ filters, onFilterChange ]);
const handleNewSocketMessage: SocketMessage.AddressTokenTransfer['handler'] = (payload) => { const handleNewSocketMessage: SocketMessage.AddressTokenTransfer['handler'] = (payload) => {
setSocketAlert(''); setShowSocketAlert(false);
const newItems: Array<TokenTransfer> = []; const newItems: Array<TokenTransfer> = [];
let newCount = 0; let newCount = 0;
...@@ -152,11 +152,11 @@ const AddressTokenTransfers = ({ overloadCount = OVERLOAD_COUNT, shouldRender = ...@@ -152,11 +152,11 @@ const AddressTokenTransfers = ({ overloadCount = OVERLOAD_COUNT, shouldRender =
}; };
const handleSocketClose = React.useCallback(() => { const handleSocketClose = React.useCallback(() => {
setSocketAlert('Connection is lost. Please refresh the page to load new token transfers.'); setShowSocketAlert(true);
}, []); }, []);
const handleSocketError = React.useCallback(() => { const handleSocketError = React.useCallback(() => {
setSocketAlert('An error has occurred while fetching new token transfers. Please refresh the page.'); setShowSocketAlert(true);
}, []); }, []);
const channel = useSocketChannel({ const channel = useSocketChannel({
...@@ -189,7 +189,7 @@ const AddressTokenTransfers = ({ overloadCount = OVERLOAD_COUNT, shouldRender = ...@@ -189,7 +189,7 @@ const AddressTokenTransfers = ({ overloadCount = OVERLOAD_COUNT, shouldRender =
top={ isActionBarHidden ? 0 : ACTION_BAR_HEIGHT_DESKTOP } top={ isActionBarHidden ? 0 : ACTION_BAR_HEIGHT_DESKTOP }
enableTimeIncrement enableTimeIncrement
showSocketInfo={ pagination.page === 1 } showSocketInfo={ pagination.page === 1 }
socketInfoAlert={ socketAlert } showSocketErrorAlert={ showSocketAlert }
socketInfoNum={ newItemsCount } socketInfoNum={ newItemsCount }
isLoading={ isPlaceholderData } isLoading={ isPlaceholderData }
/> />
...@@ -198,7 +198,7 @@ const AddressTokenTransfers = ({ overloadCount = OVERLOAD_COUNT, shouldRender = ...@@ -198,7 +198,7 @@ const AddressTokenTransfers = ({ overloadCount = OVERLOAD_COUNT, shouldRender =
{ pagination.page === 1 && ( { pagination.page === 1 && (
<SocketNewItemsNotice.Mobile <SocketNewItemsNotice.Mobile
num={ newItemsCount } num={ newItemsCount }
alert={ socketAlert } showErrorAlert={ showSocketAlert }
type="token_transfer" type="token_transfer"
isLoading={ isPlaceholderData } isLoading={ isPlaceholderData }
/> />
......
...@@ -34,7 +34,7 @@ interface Props { ...@@ -34,7 +34,7 @@ interface Props {
const BlocksContent = ({ type, query, enableSocket = true, top }: Props) => { const BlocksContent = ({ type, query, enableSocket = true, top }: Props) => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const isMobile = useIsMobile(); const isMobile = useIsMobile();
const [ socketAlert, setSocketAlert ] = React.useState(''); const [ showSocketAlert, setShowSocketAlert ] = React.useState(false);
const [ newItemsCount, setNewItemsCount ] = React.useState(0); const [ newItemsCount, setNewItemsCount ] = React.useState(0);
...@@ -66,11 +66,11 @@ const BlocksContent = ({ type, query, enableSocket = true, top }: Props) => { ...@@ -66,11 +66,11 @@ const BlocksContent = ({ type, query, enableSocket = true, top }: Props) => {
}, [ queryClient, type ]); }, [ queryClient, type ]);
const handleSocketClose = React.useCallback(() => { const handleSocketClose = React.useCallback(() => {
setSocketAlert('Connection is lost. Please refresh the page to load new blocks.'); setShowSocketAlert(true);
}, []); }, []);
const handleSocketError = React.useCallback(() => { const handleSocketError = React.useCallback(() => {
setSocketAlert('An error has occurred while fetching new blocks. Please refresh the page to load new blocks.'); setShowSocketAlert(true);
}, []); }, []);
const channel = useSocketChannel({ const channel = useSocketChannel({
...@@ -91,7 +91,7 @@ const BlocksContent = ({ type, query, enableSocket = true, top }: Props) => { ...@@ -91,7 +91,7 @@ const BlocksContent = ({ type, query, enableSocket = true, top }: Props) => {
{ query.pagination.page === 1 && enableSocket && ( { query.pagination.page === 1 && enableSocket && (
<SocketNewItemsNotice.Mobile <SocketNewItemsNotice.Mobile
num={ newItemsCount } num={ newItemsCount }
alert={ socketAlert } showErrorAlert={ showSocketAlert }
type="block" type="block"
isLoading={ query.isPlaceholderData } isLoading={ query.isPlaceholderData }
/> />
...@@ -106,7 +106,7 @@ const BlocksContent = ({ type, query, enableSocket = true, top }: Props) => { ...@@ -106,7 +106,7 @@ const BlocksContent = ({ type, query, enableSocket = true, top }: Props) => {
isLoading={ query.isPlaceholderData } isLoading={ query.isPlaceholderData }
showSocketInfo={ query.pagination.page === 1 && enableSocket } showSocketInfo={ query.pagination.page === 1 && enableSocket }
socketInfoNum={ newItemsCount } socketInfoNum={ newItemsCount }
socketInfoAlert={ socketAlert } showSocketErrorAlert={ showSocketAlert }
/> />
</Box> </Box>
</> </>
......
...@@ -19,7 +19,7 @@ interface Props { ...@@ -19,7 +19,7 @@ interface Props {
top: number; top: number;
page: number; page: number;
socketInfoNum?: number; socketInfoNum?: number;
socketInfoAlert?: string; showSocketErrorAlert?: boolean;
showSocketInfo?: boolean; showSocketInfo?: boolean;
} }
...@@ -30,7 +30,7 @@ const FEES_COL_WEIGHT = 22; ...@@ -30,7 +30,7 @@ const FEES_COL_WEIGHT = 22;
const isRollup = config.features.rollup.isEnabled; const isRollup = config.features.rollup.isEnabled;
const BlocksTable = ({ data, isLoading, top, page, showSocketInfo, socketInfoNum, socketInfoAlert }: Props) => { const BlocksTable = ({ data, isLoading, top, page, showSocketInfo, socketInfoNum, showSocketErrorAlert }: Props) => {
const initialList = useInitialList({ const initialList = useInitialList({
data: data ?? [], data: data ?? [],
idFn: (item) => item.height, idFn: (item) => item.height,
...@@ -71,7 +71,7 @@ const BlocksTable = ({ data, isLoading, top, page, showSocketInfo, socketInfoNum ...@@ -71,7 +71,7 @@ const BlocksTable = ({ data, isLoading, top, page, showSocketInfo, socketInfoNum
<TableBody> <TableBody>
{ showSocketInfo && ( { showSocketInfo && (
<SocketNewItemsNotice.Desktop <SocketNewItemsNotice.Desktop
alert={ socketInfoAlert } showErrorAlert={ showSocketErrorAlert }
num={ socketInfoNum } num={ socketInfoNum }
type="block" type="block"
isLoading={ isLoading } isLoading={ isLoading }
......
...@@ -23,7 +23,7 @@ const LatestTransactions = () => { ...@@ -23,7 +23,7 @@ const LatestTransactions = () => {
}, },
}); });
const { num, alertText } = useNewTxsSocket({ type: 'txs_home', isLoading: isPlaceholderData }); const { num, showErrorAlert } = useNewTxsSocket({ type: 'txs_home', isLoading: isPlaceholderData });
if (isError) { if (isError) {
return <Text mt={ 4 }>No data. Please reload the page.</Text>; return <Text mt={ 4 }>No data. Please reload the page.</Text>;
...@@ -33,7 +33,7 @@ const LatestTransactions = () => { ...@@ -33,7 +33,7 @@ const LatestTransactions = () => {
const txsUrl = route({ pathname: '/txs' }); const txsUrl = route({ pathname: '/txs' });
return ( return (
<> <>
<SocketNewItemsNotice borderBottomRadius={ 0 } url={ txsUrl } num={ num } alert={ alertText } isLoading={ isPlaceholderData }/> <SocketNewItemsNotice borderBottomRadius={ 0 } url={ txsUrl } num={ num } showErrorAlert={ showErrorAlert } isLoading={ isPlaceholderData }/>
<Box mb={ 3 } display={{ base: 'block', lg: 'none' }}> <Box mb={ 3 } display={{ base: 'block', lg: 'none' }}>
{ data.slice(0, txsCount).map(((tx, index) => ( { data.slice(0, txsCount).map(((tx, index) => (
<LatestTxsItemMobile <LatestTxsItemMobile
......
...@@ -22,14 +22,14 @@ const LatestArbitrumDeposits = () => { ...@@ -22,14 +22,14 @@ const LatestArbitrumDeposits = () => {
}); });
const [ num, setNum ] = useGradualIncrement(0); const [ num, setNum ] = useGradualIncrement(0);
const [ socketAlert, setSocketAlert ] = React.useState(''); const [ showSocketErrorAlert, setShowSocketErrorAlert ] = React.useState(false);
const handleSocketClose = React.useCallback(() => { const handleSocketClose = React.useCallback(() => {
setSocketAlert('Connection is lost. Please reload the page.'); setShowSocketErrorAlert(true);
}, []); }, []);
const handleSocketError = React.useCallback(() => { const handleSocketError = React.useCallback(() => {
setSocketAlert('An error has occurred while fetching new transactions. Please reload the page.'); setShowSocketErrorAlert(true);
}, []); }, []);
const handleNewDepositMessage: SocketMessage.NewArbitrumDeposits['handler'] = React.useCallback((payload) => { const handleNewDepositMessage: SocketMessage.NewArbitrumDeposits['handler'] = React.useCallback((payload) => {
...@@ -66,7 +66,7 @@ const LatestArbitrumDeposits = () => { ...@@ -66,7 +66,7 @@ const LatestArbitrumDeposits = () => {
)) } )) }
isLoading={ isPlaceholderData } isLoading={ isPlaceholderData }
socketItemsNum={ num } socketItemsNum={ num }
socketAlert={ socketAlert } showSocketErrorAlert={ showSocketErrorAlert }
/> />
); );
} }
......
...@@ -28,7 +28,7 @@ type Props = { ...@@ -28,7 +28,7 @@ type Props = {
isLoading?: boolean; isLoading?: boolean;
items: Array<DepositsItem>; items: Array<DepositsItem>;
socketItemsNum: number; socketItemsNum: number;
socketAlert?: string; showSocketErrorAlert?: boolean;
}; };
type ItemProps = { type ItemProps = {
...@@ -151,11 +151,18 @@ const LatestDepositsItem = ({ item, isLoading }: ItemProps) => { ...@@ -151,11 +151,18 @@ const LatestDepositsItem = ({ item, isLoading }: ItemProps) => {
); );
}; };
const LatestDeposits = ({ isLoading, items, socketAlert, socketItemsNum }: Props) => { const LatestDeposits = ({ isLoading, items, showSocketErrorAlert, socketItemsNum }: Props) => {
const depositsUrl = route({ pathname: '/deposits' }); const depositsUrl = route({ pathname: '/deposits' });
return ( return (
<> <>
<SocketNewItemsNotice borderBottomRadius={ 0 } url={ depositsUrl } num={ socketItemsNum } alert={ socketAlert } type="deposit" isLoading={ isLoading }/> <SocketNewItemsNotice
borderBottomRadius={ 0 }
url={ depositsUrl }
num={ socketItemsNum }
showErrorAlert={ showSocketErrorAlert }
type="deposit"
isLoading={ isLoading }
/>
<Box mb={{ base: 3, lg: 4 }}> <Box mb={{ base: 3, lg: 4 }}>
{ items.map(((item, index) => ( { items.map(((item, index) => (
<LatestDepositsItem <LatestDepositsItem
......
...@@ -22,14 +22,14 @@ const LatestOptimisticDeposits = () => { ...@@ -22,14 +22,14 @@ const LatestOptimisticDeposits = () => {
}); });
const [ num, setNum ] = useGradualIncrement(0); const [ num, setNum ] = useGradualIncrement(0);
const [ socketAlert, setSocketAlert ] = React.useState(''); const [ showSocketErrorAlert, setShowSocketErrorAlert ] = React.useState(false);
const handleSocketClose = React.useCallback(() => { const handleSocketClose = React.useCallback(() => {
setSocketAlert('Connection is lost. Please reload the page.'); setShowSocketErrorAlert(true);
}, []); }, []);
const handleSocketError = React.useCallback(() => { const handleSocketError = React.useCallback(() => {
setSocketAlert('An error has occurred while fetching new transactions. Please reload the page.'); setShowSocketErrorAlert(true);
}, []); }, []);
const handleNewDepositMessage: SocketMessage.NewOptimisticDeposits['handler'] = React.useCallback((payload) => { const handleNewDepositMessage: SocketMessage.NewOptimisticDeposits['handler'] = React.useCallback((payload) => {
...@@ -61,7 +61,7 @@ const LatestOptimisticDeposits = () => { ...@@ -61,7 +61,7 @@ const LatestOptimisticDeposits = () => {
)) } )) }
isLoading={ isPlaceholderData } isLoading={ isPlaceholderData }
socketItemsNum={ num } socketItemsNum={ num }
socketAlert={ socketAlert } showSocketErrorAlert={ showSocketErrorAlert }
/> />
); );
} }
......
...@@ -17,7 +17,7 @@ test('2 new items in validated txs list +@dark-mode', async({ render }) => { ...@@ -17,7 +17,7 @@ test('2 new items in validated txs list +@dark-mode', async({ render }) => {
}); });
test('connection loss', async({ render }) => { test('connection loss', async({ render }) => {
const component = await render(<SocketNewItemsNotice url="/" alert="Connection is lost. Please reload the page."/>, { hooksConfig }); const component = await render(<SocketNewItemsNotice url="/" showErrorAlert/>, { hooksConfig });
await expect(component).toHaveScreenshot(); await expect(component).toHaveScreenshot();
}); });
......
...@@ -15,19 +15,19 @@ interface Props { ...@@ -15,19 +15,19 @@ interface Props {
children?: (props: InjectedProps) => React.JSX.Element; children?: (props: InjectedProps) => React.JSX.Element;
className?: string; className?: string;
url?: string; url?: string;
alert?: string; showErrorAlert?: boolean;
num?: number; num?: number;
isLoading?: boolean; isLoading?: boolean;
} }
const SocketNewItemsNotice = chakra(({ children, className, url, num, alert, type = 'transaction', isLoading }: Props) => { const SocketNewItemsNotice = chakra(({ children, className, url, num, showErrorAlert, type = 'transaction', isLoading }: Props) => {
const handleLinkClick = React.useCallback(() => { const handleLinkClick = React.useCallback(() => {
window.location.reload(); window.location.reload();
}, []); }, []);
const alertContent = (() => { const alertContent = (() => {
if (alert) { if (showErrorAlert) {
return alert; return 'Live updates temporarily delayed';
} }
let name; let name;
......
...@@ -15,7 +15,7 @@ interface Props { ...@@ -15,7 +15,7 @@ interface Props {
top: number; top: number;
enableTimeIncrement?: boolean; enableTimeIncrement?: boolean;
showSocketInfo?: boolean; showSocketInfo?: boolean;
socketInfoAlert?: string; showSocketErrorAlert?: boolean;
socketInfoNum?: number; socketInfoNum?: number;
isLoading?: boolean; isLoading?: boolean;
} }
...@@ -27,7 +27,7 @@ const TokenTransferTable = ({ ...@@ -27,7 +27,7 @@ const TokenTransferTable = ({
top, top,
enableTimeIncrement, enableTimeIncrement,
showSocketInfo, showSocketInfo,
socketInfoAlert, showSocketErrorAlert,
socketInfoNum, socketInfoNum,
isLoading, isLoading,
}: Props) => { }: Props) => {
...@@ -53,7 +53,7 @@ const TokenTransferTable = ({ ...@@ -53,7 +53,7 @@ const TokenTransferTable = ({
<TableBody> <TableBody>
{ showSocketInfo && ( { showSocketInfo && (
<SocketNewItemsNotice.Desktop <SocketNewItemsNotice.Desktop
alert={ socketInfoAlert } showErrorAlert={ showSocketErrorAlert }
num={ socketInfoNum } num={ socketInfoNum }
type="token_transfer" type="token_transfer"
isLoading={ isLoading } isLoading={ isLoading }
......
...@@ -40,18 +40,18 @@ const TokenTransfer = ({ transfersQuery, tokenId, tokenQuery, tabsHeight = TABS_ ...@@ -40,18 +40,18 @@ const TokenTransfer = ({ transfersQuery, tokenId, tokenQuery, tabsHeight = TABS_
const { data: token, isPlaceholderData: isTokenPlaceholderData, isError: isTokenError } = tokenQuery; const { data: token, isPlaceholderData: isTokenPlaceholderData, isError: isTokenError } = tokenQuery;
const [ newItemsCount, setNewItemsCount ] = useGradualIncrement(0); const [ newItemsCount, setNewItemsCount ] = useGradualIncrement(0);
const [ socketAlert, setSocketAlert ] = React.useState(''); const [ showSocketErrorAlert, setShowSocketErrorAlert ] = React.useState(false);
const handleNewTransfersMessage: SocketMessage.TokenTransfers['handler'] = (payload) => { const handleNewTransfersMessage: SocketMessage.TokenTransfers['handler'] = (payload) => {
setNewItemsCount(payload.token_transfer); setNewItemsCount(payload.token_transfer);
}; };
const handleSocketClose = React.useCallback(() => { const handleSocketClose = React.useCallback(() => {
setSocketAlert('Connection is lost. Please refresh the page to load new token transfers.'); setShowSocketErrorAlert(true);
}, []); }, []);
const handleSocketError = React.useCallback(() => { const handleSocketError = React.useCallback(() => {
setSocketAlert('An error has occurred while fetching new token transfers. Please refresh the page.'); setShowSocketErrorAlert(true);
}, []); }, []);
const channel = useSocketChannel({ const channel = useSocketChannel({
...@@ -79,7 +79,7 @@ const TokenTransfer = ({ transfersQuery, tokenId, tokenQuery, tabsHeight = TABS_ ...@@ -79,7 +79,7 @@ const TokenTransfer = ({ transfersQuery, tokenId, tokenQuery, tabsHeight = TABS_
data={ data?.items } data={ data?.items }
top={ tabsHeight } top={ tabsHeight }
showSocketInfo={ pagination.page === 1 } showSocketInfo={ pagination.page === 1 }
socketInfoAlert={ socketAlert } showSocketErrorAlert={ showSocketErrorAlert }
socketInfoNum={ newItemsCount } socketInfoNum={ newItemsCount }
tokenId={ tokenId } tokenId={ tokenId }
token={ token } token={ token }
...@@ -91,7 +91,7 @@ const TokenTransfer = ({ transfersQuery, tokenId, tokenQuery, tabsHeight = TABS_ ...@@ -91,7 +91,7 @@ const TokenTransfer = ({ transfersQuery, tokenId, tokenQuery, tabsHeight = TABS_
{ pagination.page === 1 && ( { pagination.page === 1 && (
<SocketNewItemsNotice.Mobile <SocketNewItemsNotice.Mobile
num={ newItemsCount } num={ newItemsCount }
alert={ socketAlert } showErrorAlert={ showSocketErrorAlert }
type="token_transfer" type="token_transfer"
isLoading={ isLoading } isLoading={ isLoading }
/> />
......
...@@ -15,7 +15,7 @@ interface Props { ...@@ -15,7 +15,7 @@ interface Props {
data: Array<TokenTransfer>; data: Array<TokenTransfer>;
top: number; top: number;
showSocketInfo: boolean; showSocketInfo: boolean;
socketInfoAlert?: string; showSocketErrorAlert?: boolean;
socketInfoNum?: number; socketInfoNum?: number;
tokenId?: string; tokenId?: string;
isLoading?: boolean; isLoading?: boolean;
...@@ -23,7 +23,7 @@ interface Props { ...@@ -23,7 +23,7 @@ interface Props {
instance?: TokenInstance; instance?: TokenInstance;
} }
const TokenTransferTable = ({ data, top, showSocketInfo, socketInfoAlert, socketInfoNum, tokenId, isLoading, token, instance }: Props) => { const TokenTransferTable = ({ data, top, showSocketInfo, showSocketErrorAlert, socketInfoNum, tokenId, isLoading, token, instance }: Props) => {
const tokenType = token.type; const tokenType = token.type;
...@@ -51,7 +51,7 @@ const TokenTransferTable = ({ data, top, showSocketInfo, socketInfoAlert, socket ...@@ -51,7 +51,7 @@ const TokenTransferTable = ({ data, top, showSocketInfo, socketInfoAlert, socket
<TableBody> <TableBody>
{ showSocketInfo && ( { showSocketInfo && (
<SocketNewItemsNotice.Desktop <SocketNewItemsNotice.Desktop
alert={ socketInfoAlert } showErrorAlert={ showSocketErrorAlert }
num={ socketInfoNum } num={ socketInfoNum }
type="token_transfer" type="token_transfer"
isLoading={ isLoading } isLoading={ isLoading }
......
...@@ -12,7 +12,7 @@ interface Props { ...@@ -12,7 +12,7 @@ interface Props {
} }
const TxsSocketNoticeTypeAddress = ({ place, isLoading }: Props) => { const TxsSocketNoticeTypeAddress = ({ place, isLoading }: Props) => {
const { num, alertText } = useTxsSocketTypeAddress({ isLoading }); const { num, showErrorAlert } = useTxsSocketTypeAddress({ isLoading });
if (num === undefined) { if (num === undefined) {
return null; return null;
...@@ -21,7 +21,7 @@ const TxsSocketNoticeTypeAddress = ({ place, isLoading }: Props) => { ...@@ -21,7 +21,7 @@ const TxsSocketNoticeTypeAddress = ({ place, isLoading }: Props) => {
if (place === 'table') { if (place === 'table') {
return ( return (
<SocketNewItemsNotice.Desktop <SocketNewItemsNotice.Desktop
alert={ alertText } showErrorAlert={ showErrorAlert }
num={ num } num={ num }
isLoading={ isLoading } isLoading={ isLoading }
/> />
...@@ -32,7 +32,7 @@ const TxsSocketNoticeTypeAddress = ({ place, isLoading }: Props) => { ...@@ -32,7 +32,7 @@ const TxsSocketNoticeTypeAddress = ({ place, isLoading }: Props) => {
return ( return (
<SocketNewItemsNotice.Mobile <SocketNewItemsNotice.Mobile
num={ num } num={ num }
alert={ alertText } showErrorAlert={ showErrorAlert }
isLoading={ isLoading } isLoading={ isLoading }
/> />
); );
......
...@@ -17,7 +17,7 @@ interface Props { ...@@ -17,7 +17,7 @@ interface Props {
const TxsSocketNoticeTypeAll = ({ type, place, isLoading }: Props) => { const TxsSocketNoticeTypeAll = ({ type, place, isLoading }: Props) => {
const multichainContext = useMultichainContext(); const multichainContext = useMultichainContext();
const { num, alertText } = useNewTxsSocketTypeAll({ type, isLoading }); const { num, showErrorAlert } = useNewTxsSocketTypeAll({ type, isLoading });
if (num === undefined) { if (num === undefined) {
return null; return null;
...@@ -36,7 +36,7 @@ const TxsSocketNoticeTypeAll = ({ type, place, isLoading }: Props) => { ...@@ -36,7 +36,7 @@ const TxsSocketNoticeTypeAll = ({ type, place, isLoading }: Props) => {
if (place === 'table') { if (place === 'table') {
return ( return (
<SocketNewItemsNotice.Desktop <SocketNewItemsNotice.Desktop
alert={ alertText } showErrorAlert={ showErrorAlert }
num={ num } num={ num }
isLoading={ isLoading } isLoading={ isLoading }
url={ url } url={ url }
...@@ -48,7 +48,7 @@ const TxsSocketNoticeTypeAll = ({ type, place, isLoading }: Props) => { ...@@ -48,7 +48,7 @@ const TxsSocketNoticeTypeAll = ({ type, place, isLoading }: Props) => {
return ( return (
<SocketNewItemsNotice.Mobile <SocketNewItemsNotice.Mobile
num={ num } num={ num }
alert={ alertText } showErrorAlert={ showErrorAlert }
isLoading={ isLoading } isLoading={ isLoading }
url={ url } url={ url }
/> />
......
...@@ -38,7 +38,7 @@ interface Params { ...@@ -38,7 +38,7 @@ interface Params {
} }
export default function useTxsSocketTypeAddress({ isLoading }: Params) { export default function useTxsSocketTypeAddress({ isLoading }: Params) {
const [ alertText, setAlertText ] = React.useState(''); const [ showErrorAlert, setShowErrorAlert ] = React.useState(false);
const [ num, setNum ] = React.useState(0); const [ num, setNum ] = React.useState(0);
const router = useRouter(); const router = useRouter();
...@@ -51,12 +51,12 @@ export default function useTxsSocketTypeAddress({ isLoading }: Params) { ...@@ -51,12 +51,12 @@ export default function useTxsSocketTypeAddress({ isLoading }: Params) {
const { chain } = useMultichainContext() || {}; const { chain } = useMultichainContext() || {};
const handleNewSocketMessage: SocketMessage.AddressTxs['handler'] = React.useCallback((payload) => { const handleNewSocketMessage: SocketMessage.AddressTxs['handler'] = React.useCallback((payload) => {
setAlertText('');
const queryKey = getResourceKey('general:address_txs', { const queryKey = getResourceKey('general:address_txs', {
pathParams: { hash: currentAddress }, pathParams: { hash: currentAddress },
queryParams: filterValue ? { filter: filterValue } : undefined, queryParams: filterValue ? { filter: filterValue } : undefined,
chainSlug: chain?.slug, chainSlug: chain?.slug,
}); });
setShowErrorAlert(false);
queryClient.setQueryData( queryClient.setQueryData(
queryKey, queryKey,
...@@ -100,11 +100,11 @@ export default function useTxsSocketTypeAddress({ isLoading }: Params) { ...@@ -100,11 +100,11 @@ export default function useTxsSocketTypeAddress({ isLoading }: Params) {
}, [ currentAddress, filterValue, queryClient, sort, chain?.slug ]); }, [ currentAddress, filterValue, queryClient, sort, chain?.slug ]);
const handleSocketClose = React.useCallback(() => { const handleSocketClose = React.useCallback(() => {
setAlertText('Connection is lost. Please refresh the page to load new transactions.'); setShowErrorAlert(true);
}, []); }, []);
const handleSocketError = React.useCallback(() => { const handleSocketError = React.useCallback(() => {
setAlertText('An error has occurred while fetching new transactions. Please refresh the page.'); setShowErrorAlert(true);
}, []); }, []);
const isDisabled = Boolean((page && page !== '1') || isLoading); const isDisabled = Boolean((page && page !== '1') || isLoading);
...@@ -132,5 +132,5 @@ export default function useTxsSocketTypeAddress({ isLoading }: Params) { ...@@ -132,5 +132,5 @@ export default function useTxsSocketTypeAddress({ isLoading }: Params) {
return { }; return { };
} }
return { num, alertText }; return { num, showErrorAlert };
} }
...@@ -45,7 +45,7 @@ export default function useNewTxsSocketTypeAll({ type, isLoading }: Params) { ...@@ -45,7 +45,7 @@ export default function useNewTxsSocketTypeAll({ type, isLoading }: Params) {
const page = getQueryParamString(router.query.page); const page = getQueryParamString(router.query.page);
const [ num, setNum ] = useGradualIncrement(0); const [ num, setNum ] = useGradualIncrement(0);
const [ alertText, setAlertText ] = React.useState(''); const [ showErrorAlert, setShowErrorAlert ] = React.useState(false);
const { topic, event } = getSocketParams(type, page); const { topic, event } = getSocketParams(type, page);
...@@ -59,11 +59,11 @@ export default function useNewTxsSocketTypeAll({ type, isLoading }: Params) { ...@@ -59,11 +59,11 @@ export default function useNewTxsSocketTypeAll({ type, isLoading }: Params) {
}, [ setNum ]); }, [ setNum ]);
const handleSocketClose = React.useCallback(() => { const handleSocketClose = React.useCallback(() => {
setAlertText('Connection is lost. Please reload the page.'); setShowErrorAlert(true);
}, []); }, []);
const handleSocketError = React.useCallback(() => { const handleSocketError = React.useCallback(() => {
setAlertText('An error has occurred while fetching new transactions. Please reload the page.'); setShowErrorAlert(true);
}, []); }, []);
const channel = useSocketChannel({ const channel = useSocketChannel({
...@@ -83,5 +83,5 @@ export default function useNewTxsSocketTypeAll({ type, isLoading }: Params) { ...@@ -83,5 +83,5 @@ export default function useNewTxsSocketTypeAll({ type, isLoading }: Params) {
return { }; return { };
} }
return { num, alertText }; return { num, showErrorAlert };
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment