|
1 | 1 | import { Graph, type Op } from '@graphprotocol/grc-20';
|
2 | 2 | import type { Connect } from '@graphprotocol/hypergraph';
|
| 3 | +import { Constants } from '@graphprotocol/hypergraph'; |
3 | 4 | import { useQueryClient } from '@tanstack/react-query';
|
| 5 | +import * as Option from 'effect/Option'; |
4 | 6 | import type * as Schema from 'effect/Schema';
|
| 7 | +import * as SchemaAST from 'effect/SchemaAST'; |
5 | 8 | import request, { gql } from 'graphql-request';
|
6 | 9 | import { publishOps } from '../publish-ops.js';
|
7 | 10 |
|
@@ -70,16 +73,22 @@ export const useDeleteEntityPublic = <S extends Schema.Schema.AnyNoContext>(
|
70 | 73 | name: `Delete entity ${id}`,
|
71 | 74 | walletClient,
|
72 | 75 | });
|
| 76 | + |
| 77 | + const typeIds = SchemaAST.getAnnotation<string[]>(Constants.TypeIdsSymbol)( |
| 78 | + type.ast as SchemaAST.TypeLiteral, |
| 79 | + ).pipe(Option.getOrElse(() => [])); |
| 80 | + |
73 | 81 | // TODO: temporary fix until we get the information from the API when a transaction is confirmed
|
74 | 82 | await new Promise((resolve) => setTimeout(resolve, 2000));
|
75 |
| - queryClient.invalidateQueries({ |
76 |
| - queryKey: [ |
77 |
| - 'hypergraph-public-entities', |
78 |
| - // @ts-expect-error - TODO: find a better way to access the type.name |
79 |
| - type.name, |
80 |
| - space, |
81 |
| - ], |
82 |
| - }); |
| 83 | + if (typeIds.length > 0) { |
| 84 | + queryClient.invalidateQueries({ |
| 85 | + queryKey: ['hypergraph-public-entities', space, typeIds], |
| 86 | + }); |
| 87 | + } else { |
| 88 | + queryClient.invalidateQueries({ |
| 89 | + queryKey: ['hypergraph-public-entities', space], |
| 90 | + }); |
| 91 | + } |
83 | 92 |
|
84 | 93 | return { success: true, cid, txResult };
|
85 | 94 | } catch (_error) {
|
|
0 commit comments