| 15 | ` |
| 16 | |
| 17 | export function makeDeleteLinkCallback({ selectedRepoId, linkId }: { |
| 18 | linkId: string, |
| 19 | selectedRepoId: string | null, |
| 20 | }) { |
| 21 | const deleteLink = useMutation<deleteLinkMutation>(query)[0] |
| 22 | |
| 23 | const updater = (store: RecordSourceSelectorProxy) => { |
| 24 | store.delete(linkId) |
| 25 | } |
| 26 | |
| 27 | return useCallback(() => { |
| 28 | if (!selectedRepoId) { |
| 29 | console.log('no repo selected') |
| 30 | return |
| 31 | } |
| 32 | |
| 33 | deleteLink({ |
| 34 | variables: { |
| 35 | input: { repoId: selectedRepoId, linkId }, |
| 36 | }, |
| 37 | optimisticUpdater: updater, |
| 38 | updater, |
| 39 | }) |
| 40 | }, [deleteLink, selectedRepoId, linkId, updater]) |
| 41 | } |