diff --git a/src/segments/Spambox.tsx b/src/segments/Spambox.tsx
index 154a89cacf..f51cbcc616 100644
--- a/src/segments/Spambox.tsx
+++ b/src/segments/Spambox.tsx
@@ -1,20 +1,23 @@
// React + Web3 Essentials
-import React from "react";
+import React from 'react';
// External Packages
-import styled from "styled-components";
+import styled from 'styled-components';
// Internal components
-import SpamBox from "segments/spam";
+import SpamBox from 'segments/Spam';
// Create Header
function Spambox(props) {
-
// Render
return (
-
+
);
}
diff --git a/src/segments/spam.tsx b/src/segments/spam.tsx
index ac3b8547ad..b46652d847 100644
--- a/src/segments/spam.tsx
+++ b/src/segments/spam.tsx
@@ -7,7 +7,7 @@ import { toast as toaster } from 'react-toastify';
import { useClickAway } from 'react-use';
import { Waypoint } from 'react-waypoint';
import styled, { ThemeProvider, useTheme } from 'styled-components';
-import { MdCheckCircle, MdError } from "react-icons/md";
+import { MdCheckCircle, MdError } from 'react-icons/md';
// Internal Components
import * as PushAPI from '@pushprotocol/restapi';
@@ -20,7 +20,7 @@ import {
addPaginatedNotifications,
incrementPage,
setFinishedFetching,
- updateTopNotifications
+ updateTopNotifications,
} from 'redux/slices/spamSlice';
import SearchFilter from '../components/SearchFilter';
import DisplayNotice from '../primaries/DisplayNotice';
@@ -31,7 +31,7 @@ import { ScrollItem } from './ViewChannels';
import { useAccount } from 'hooks';
// Internal Configs
-import { appConfig } from "config";
+import { appConfig } from 'config';
import { device } from 'config/Globals';
import { AppContext } from 'contexts/AppContext';
@@ -43,7 +43,7 @@ const SpamBox = ({ showFilter, setShowFilter, search, setSearch }) => {
const dispatch = useDispatch();
const { userPushSDKInstance } = useSelector((state: any) => {
return state.user;
- });
+ });
const modalRef = React.useRef(null);
useClickAway(modalRef, () => showFilter && setShowFilter(false));
const { account, chainId, provider } = useAccount();
@@ -63,7 +63,7 @@ const SpamBox = ({ showFilter, setShowFilter, search, setSearch }) => {
const EPNS_DOMAIN = {
name: 'EPNS COMM V1',
chainId: chainId,
- verifyingContract: epnsCommReadProvider?.address
+ verifyingContract: epnsCommReadProvider?.address,
};
const [allNotif, setNotif] = React.useState([]);
const [loadFilter, setLoadFilter] = React.useState(false);
@@ -94,7 +94,7 @@ const SpamBox = ({ showFilter, setShowFilter, search, setSearch }) => {
ETH_TEST_GOERLI: 5,
ETH_TEST_SEPOLIA: 11155111,
POLYGON_MAINNET: 137,
- ETH_MAINNET: 1
+ ETH_MAINNET: 1,
};
const reset = () => setFilter(false);
@@ -109,7 +109,7 @@ const SpamBox = ({ showFilter, setShowFilter, search, setSearch }) => {
endDate = endDate.getTime() / 1000;
var Filter = {
channels: channels,
- date: { lowDate: startDate, highDate: endDate }
+ date: { lowDate: startDate, highDate: endDate },
};
if (channels.length == 0) delete Filter.channels;
@@ -149,7 +149,7 @@ const SpamBox = ({ showFilter, setShowFilter, search, setSearch }) => {
const results = await userPushSDKInstance.notification.list('SPAM', {
limit: NOTIFICATIONS_PER_PAGE,
page: page,
- raw: true
+ raw: true,
});
let parsedResponse = PushAPI.utils.parseApiResponse(results);
parsedResponse.forEach((each, i) => {
@@ -191,7 +191,7 @@ const SpamBox = ({ showFilter, setShowFilter, search, setSearch }) => {
const results = await userPushSDKInstance.notification.list('SPAM', {
limit: NOTIFICATIONS_PER_PAGE,
page: 1,
- raw: true
+ raw: true,
});
if (!notifications.length) {
dispatch(incrementPage());
@@ -239,7 +239,7 @@ const SpamBox = ({ showFilter, setShowFilter, search, setSearch }) => {
const results = await userPushSDKInstance.notification.list('SPAM', {
limit: 100000,
page: 1,
- raw: true
+ raw: true,
});
if (!notifications.length) {
@@ -270,7 +270,7 @@ const SpamBox = ({ showFilter, setShowFilter, search, setSearch }) => {
dispatch(
updateTopNotifications({
notifs: res,
- pageSize: NOTIFICATIONS_PER_PAGE
+ pageSize: NOTIFICATIONS_PER_PAGE,
})
);
setNotif(res);
@@ -295,8 +295,6 @@ const SpamBox = ({ showFilter, setShowFilter, search, setSearch }) => {
}
}, [epnsCommReadProvider, account]);
-
-
//function to query more notifications
const handlePagination = async () => {
loadNotifications();
@@ -312,11 +310,9 @@ const SpamBox = ({ showFilter, setShowFilter, search, setSearch }) => {
if (!channelAddress) return;
let address = channelAddress;
-
-
if (!address) return;
console.debug(address);
- subscribeToast.showLoaderToast({loaderMessage: "Waiting for Confirmation..."});
+ subscribeToast.showLoaderToast({ loaderMessage: 'Waiting for Confirmation...' });
console.debug(provider, account);
const _signer = await provider.getSigner(account);
console.debug(_signer);
@@ -324,31 +320,41 @@ const SpamBox = ({ showFilter, setShowFilter, search, setSearch }) => {
signer: _signer,
channelAddress: convertAddressToAddrCaip(channelAddress, nameToId[blockchain]), // channel address in CAIP
userAddress: convertAddressToAddrCaip(account, chainId), // user address in CAIP
- })
+ });
await PushAPI.channels.subscribe({
signer: _signer,
channelAddress: convertAddressToAddrCaip(channelAddress, chainId), // channel address in CAIP
userAddress: convertAddressToAddrCaip(account, chainId), // user address in CAIP
onSuccess: () => {
subscribeToast.showMessageToast({
- toastTitle:"Success",
- toastMessage: "Successfully opted into channel !",
- toastType: "SUCCESS",
- getToastIcon: (size) =>
- })
+ toastTitle: 'Success',
+ toastMessage: 'Successfully opted into channel !',
+ toastType: 'SUCCESS',
+ getToastIcon: (size) => (
+
+ ),
+ });
dispatch(updateSubscriptionStatus({ channelAddress: channelAddress, status: true }));
},
onError: (err) => {
console.error(err);
subscribeToast.showMessageToast({
- toastTitle:"Error",
- toastMessage: `There was an error opting into channel`,
- toastType: "ERROR",
- getToastIcon: (size) =>
- })
+ toastTitle: 'Error',
+ toastMessage: `There was an error opting into channel`,
+ toastType: 'ERROR',
+ getToastIcon: (size) => (
+
+ ),
+ });
},
- env: appConfig.pushNodesEnv
- })
+ env: appConfig.pushNodesEnv,
+ });
};
const isSubscribedFn = (channel: string) => {
@@ -384,7 +390,7 @@ const SpamBox = ({ showFilter, setShowFilter, search, setSearch }) => {
closeOnClick: true,
pauseOnHover: true,
draggable: true,
- progress: undefined
+ progress: undefined,
});
} else if (error.code === -32601) {
console.error(error);
@@ -396,7 +402,7 @@ const SpamBox = ({ showFilter, setShowFilter, search, setSearch }) => {
closeOnClick: true,
pauseOnHover: true,
draggable: true,
- progress: undefined
+ progress: undefined,
});
} else {
console.error(error);
@@ -408,7 +414,7 @@ const SpamBox = ({ showFilter, setShowFilter, search, setSearch }) => {
closeOnClick: true,
pauseOnHover: true,
draggable: true,
- progress: undefined
+ progress: undefined,
});
}
}
@@ -432,59 +438,53 @@ const SpamBox = ({ showFilter, setShowFilter, search, setSearch }) => {
/>
- {notifications && (
-
- {bgUpdateLoading && (
- -
-
-
- )}
- {(filter && !run ? filteredNotifications : allNotif).map((oneNotification, index) => {
- const {
- cta,
- title,
- message,
- app,
- icon,
- image,
- secret,
- notification,
- channel,
- blockchain,
- url
- } = oneNotification;
- // render the notification item
- return (
-
- {showWayPoint(index) && !loading && }
- onSubscribeToChannel(channel, blockchain)}
- isSpam
- isSubscribedFn={async () => isSubscribedFn(channel)}
- isSecret={secret != ''}
- decryptFn={() => onDecrypt({ secret, title, message, image, cta })}
- chainName={blockchain}
- url={url}
- />
-
- );
- })}
- {loading && !bgUpdateLoading && }
-
- )}
- {(!notifications.length || (filter && !filteredNotifications.length)) && !loading && (
-
-
-
- )}
- {toast && }
+ {notifications && (
+
+ {bgUpdateLoading && (
+ -
+
+
+ )}
+ {(filter && !run ? filteredNotifications : allNotif).map((oneNotification, index) => {
+ const { cta, title, message, app, icon, image, secret, notification, channel, blockchain, url } =
+ oneNotification;
+ // render the notification item
+ return (
+
+ {showWayPoint(index) && !loading && }
+ onSubscribeToChannel(channel, blockchain)}
+ isSpam
+ isSubscribedFn={async () => isSubscribedFn(channel)}
+ isSecret={secret != ''}
+ decryptFn={() => onDecrypt({ secret, title, message, image, cta })}
+ chainName={blockchain}
+ url={url}
+ />
+
+ );
+ })}
+ {loading && !bgUpdateLoading && }
+
+ )}
+ {(!notifications.length || (filter && !filteredNotifications.length)) && !loading && (
+
+
+
+ )}
+ {toast && (
+
+ )}