Skip to content

Commit

Permalink
chore: fix dnode dapp
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman035 committed Jul 8, 2024
1 parent f3718c2 commit 65f662f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
7 changes: 4 additions & 3 deletions packages/dnode/tests/lib/notification/channel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ describe('PushAPI.channel functionality', () => {
it('With signer : broadcast : Should send notification with title and body', async () => {
const res = await userAlice.channel.send(['*'], {
notification: {
title: 'test',
body: 'test',
title: 'Testing new notif',
body: 'test new notif',
},
});
console.log(res);
expect(res.status).to.equal(200);
});

Expand All @@ -155,7 +156,7 @@ describe('PushAPI.channel functionality', () => {

it('With signer : targeted : Should send notification with title and body', async () => {
const res = await userAlice.channel.send(
['eip155:11155111:0x93A829d16DE51745Db0530A0F8E8A9B8CA5370E5'],
['eip155:11155111:0xD8634C39BBFd4033c0d3289C4515275102423681'],
{
notification: {
title: 'hi',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const SendNotification: React.FC = () => {
if (isConnected && walletClient.data && channel === '') {
try {
const channelInfo = await getChannelInfo(walletClient.data);
if (channelInfo !== null) {
if (channelInfo !== null && channelInfo.processed == 1) {
setAllowNotification(true);
setChannel(channelInfo.channel);
setErrorMessage(''); // Clear error message if the channel is found
Expand Down
5 changes: 4 additions & 1 deletion packages/examples/dnode-dapp/src/components/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import { MagnifyingGlassIcon } from '@heroicons/react/24/outline';
import { useRouter } from 'next/router';
import { getCheckSumAddress } from '../utils';

const SearchBar: React.FC = () => {
const [searchTerm, setSearchTerm] = useState('');
Expand All @@ -9,7 +10,9 @@ const SearchBar: React.FC = () => {
const handleSearch = () => {
if (searchTerm.trim()) {
// Navigate to the search results page
router.push(`/pushscan/${encodeURIComponent(searchTerm.trim())}`);
router.push(
`/pushscan/${encodeURIComponent(getCheckSumAddress(searchTerm.trim()))}`
);
}
};

Expand Down
24 changes: 16 additions & 8 deletions packages/examples/dnode-dapp/src/pages/pushscan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { useState, useEffect } from 'react';
import SearchBar from '../../components/SearchBar';
import { useRouter } from 'next/router';
import Link from 'next/link';
import { getRecentTransactionAccounts } from '../../utils/push';
import { getCheckSumAddress } from '../../utils';

export default function Explorer() {
const [page, setPage] = useState(1);
Expand Down Expand Up @@ -32,19 +34,25 @@ export default function Explorer() {
const router = useRouter();

const handleClick = (address: string) => {
router.push(`/pushscan/${address}`);
router.push(`/pushscan/${getCheckSumAddress(address)}`);
};

useEffect(() => {
// Fetch initial stats and latest blocks
const fetchData = async () => {
// TODO: Fetch all address notif
// const statsData = await fetchNetworkStats();
// const latestBlocksData = await fetchLatestBlocks(30);
// setStats(statsData);
// setLatestBlocks(latestBlocksData);
const recipients = await getRecentTransactionAccounts();
console.log(recipients);
// setLatestNotifications(recipients);
};

// Polling function
const intervalId = setInterval(fetchData, 30000); // 30000 ms = 30 seconds

// Fetch data immediately on component mount
fetchData();

// Clear interval on component unmount
return () => clearInterval(intervalId);
}, []);

return (
Expand Down Expand Up @@ -94,14 +102,14 @@ export default function Explorer() {
Previous Page
</button>
)}
{page * size < total && (
{/* {page * size < total && (
<button
onClick={handleNextPage}
className="rounded-md bg-indigo-600 px-4 py-2 text-sm font-semibold text-white hover:bg-indigo-500"
>
Next Page
</button>
)}
)} */}
</div>
</div>
);
Expand Down

0 comments on commit 65f662f

Please sign in to comment.