From cdf022e48e66657866dd5db6707ea259ddddd4f1 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 7 Aug 2024 10:58:05 -0500 Subject: [PATCH] Handle failed reattachment req --- src/state/queries/postgate/index.ts | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/state/queries/postgate/index.ts b/src/state/queries/postgate/index.ts index e3d2bd845d..5f9d5011bb 100644 --- a/src/state/queries/postgate/index.ts +++ b/src/state/queries/postgate/index.ts @@ -7,6 +7,7 @@ import { import {useMutation, useQueryClient} from '@tanstack/react-query' import {networkRetry} from '#/lib/async/retry' +import {logger} from '#/logger' import {updatePostShadow} from '#/state/cache/post-shadow' import {useGetPosts} from '#/state/queries/post' import { @@ -156,15 +157,22 @@ export function useToggleQuoteDetachmentMutation() { }), }) } else if (action === 'reattach') { - const [quote] = await getPosts({uris: [quoteUri]}) - updatePostShadow(queryClient, post.uri, { - embed: createMaybeDetachedQuoteEmbed({ - post, - quote, - quoteUri: undefined, - detached: false, - }), - }) + try { + const [quote] = await getPosts({uris: [quoteUri]}) + updatePostShadow(queryClient, post.uri, { + embed: createMaybeDetachedQuoteEmbed({ + post, + quote, + quoteUri: undefined, + detached: false, + }), + }) + } catch (e: any) { + // ok if this fails, it's just optimistic UI + logger.error(`Postgate: failed to get quote post for re-attachment`, { + safeMessage: e.message, + }) + } } }, })