Handle failed reattachment req
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
|||||||
import {useMutation, useQueryClient} from '@tanstack/react-query'
|
import {useMutation, useQueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {networkRetry} from '#/lib/async/retry'
|
import {networkRetry} from '#/lib/async/retry'
|
||||||
|
import {logger} from '#/logger'
|
||||||
import {updatePostShadow} from '#/state/cache/post-shadow'
|
import {updatePostShadow} from '#/state/cache/post-shadow'
|
||||||
import {useGetPosts} from '#/state/queries/post'
|
import {useGetPosts} from '#/state/queries/post'
|
||||||
import {
|
import {
|
||||||
@@ -156,15 +157,22 @@ export function useToggleQuoteDetachmentMutation() {
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
} else if (action === 'reattach') {
|
} else if (action === 'reattach') {
|
||||||
const [quote] = await getPosts({uris: [quoteUri]})
|
try {
|
||||||
updatePostShadow(queryClient, post.uri, {
|
const [quote] = await getPosts({uris: [quoteUri]})
|
||||||
embed: createMaybeDetachedQuoteEmbed({
|
updatePostShadow(queryClient, post.uri, {
|
||||||
post,
|
embed: createMaybeDetachedQuoteEmbed({
|
||||||
quote,
|
post,
|
||||||
quoteUri: undefined,
|
quote,
|
||||||
detached: false,
|
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,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user