Skip to content

Commit 817e7dc

Browse files
committed
Display a toaster when a claim is verified
1 parent 6a9e67e commit 817e7dc

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

apps/polycentric/src/features/verifications/hooks/useVerifyClaim.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ jest.mock('@/src/common/query/hooks/useQuery', () => ({
3535
invalidateQuery: jest.fn(),
3636
}));
3737

38+
// The toast barrel pulls in Toaster, whose @rn-primitives/portal dependency
39+
// ships untranspiled JSX that jest can't parse.
40+
const mockToast = { success: jest.fn(), error: jest.fn() };
41+
jest.mock('@/src/common/components/toast', () => ({
42+
useToast: () => mockToast,
43+
}));
44+
3845
import { invalidateQuery } from '@/src/common/query/hooks/useQuery';
3946
import { v2 } from '@polycentric/react-native';
4047
import * as React from 'react';
@@ -90,6 +97,7 @@ describe('useVerifyClaim', () => {
9097

9198
expect(mockClient.buildEvent).toHaveBeenCalledWith(content, 8);
9299
expect(mockClient.sync).toHaveBeenCalledWith('partial-push');
100+
expect(mockToast.success).toHaveBeenCalled();
93101
});
94102

95103
it('refreshes the verifiers list and the verification inbox', async () => {

apps/polycentric/src/features/verifications/hooks/useVerifyClaim.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useToast } from '@/src/common/components/toast';
12
import {
23
hexToBytes,
34
useCurrentIdentity,
@@ -13,6 +14,7 @@ export default function useVerifyClaim() {
1314
const client = usePolycentric();
1415
const { identityKey } = useCurrentIdentity();
1516
const [isPending, setPending] = useState(false);
17+
const toast = useToast();
1618

1719
return {
1820
isPending,
@@ -42,6 +44,8 @@ export default function useVerifyClaim() {
4244
const signedEvent = await client.signEvent(event);
4345
await client.commitEvent(signedEvent, content);
4446

47+
toast.success('Verified!');
48+
4549
// Delivery to servers is best-effort — the verify is already saved
4650
// locally and will be pushed on the next sync if this fails.
4751
try {

0 commit comments

Comments
 (0)