From 732a43f36cba01cf8427910b5a6fbf68f7dfd0b7 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 10 Feb 2026 00:30:40 +0000 Subject: [PATCH] allow undo delete --- src/screens/Profile/components/GermButton.tsx | 57 +++++++++++++++---- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/src/screens/Profile/components/GermButton.tsx b/src/screens/Profile/components/GermButton.tsx index 829ebe998b..55858263da 100644 --- a/src/screens/Profile/components/GermButton.tsx +++ b/src/screens/Profile/components/GermButton.tsx @@ -88,23 +88,56 @@ function GermSelfButton({did}: {did: string}) { const t = useTheme() const queryClient = useQueryClient() - const {mutate, isPending} = useMutation({ + const {mutate: deleteDeclaration, isPending} = useMutation({ onMutate: async () => { + const previousRecord = await agent.com.germnetwork.declaration + .get({ + repo: did, + rkey: 'self', + }) + .then(res => res.value) + .catch(() => null) + await agent.com.germnetwork.declaration.delete({ repo: did, rkey: 'self', }) await whenAppViewReady(agent, did, res => !res.data.associated?.germ) + + return previousRecord }, - onSuccess: () => { - selfExplanationDialogControl.close(() => { - Toast.show( - _( - msg`Germ DM link disconnected. You can reconnect it at any time through the Germ app.`, - ), + onSuccess: (_data, _variables, previousRecord) => { + async function undo() { + if (!previousRecord) return + await agent.com.germnetwork.declaration.put( + { + repo: did, + rkey: 'self', + }, + previousRecord, ) + await whenAppViewReady(agent, did, res => !!res.data.associated?.germ) + await queryClient.refetchQueries({queryKey: RQKEY(did)}) + + Toast.show(_(msg`Germ DM reconnected`)) + } + + selfExplanationDialogControl.close(() => { void queryClient.refetchQueries({queryKey: RQKEY(did)}) + Toast.show( + + + + Germ DM disconnected + + {previousRecord && ( + void undo()}> + Undo + + )} + , + ) }) }, onError: error => { @@ -154,21 +187,21 @@ function GermSelfButton({did}: {did: string}) { can manage its visibility from the Germ DM app. - +