From 68bb17a00a835e4375ab2c72b4badca441c59d2a Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Mon, 20 Mar 2023 19:14:20 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Stop=20invalidating=20quer?= =?UTF-8?q?ies=20on=20page=20load?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/components/poll/use-touch-beacon.ts | 4 +++- apps/web/src/utils/trpc.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/poll/use-touch-beacon.ts b/apps/web/src/components/poll/use-touch-beacon.ts index 00f190488..af99cf4b0 100644 --- a/apps/web/src/components/poll/use-touch-beacon.ts +++ b/apps/web/src/components/poll/use-touch-beacon.ts @@ -7,7 +7,9 @@ import { trpc } from "../../utils/trpc"; * find polls that haven't been accessed for some time so that they can be deleted by house keeping. */ export const useTouchBeacon = (pollId: string) => { - const touchMutation = trpc.polls.touch.useMutation(); + const touchMutation = trpc.polls.touch.useMutation({ + meta: { doNotInvalidate: true }, + }); useMount(() => { touchMutation.mutate({ pollId }); diff --git a/apps/web/src/utils/trpc.ts b/apps/web/src/utils/trpc.ts index ad5c2397d..041718354 100644 --- a/apps/web/src/utils/trpc.ts +++ b/apps/web/src/utils/trpc.ts @@ -16,7 +16,9 @@ export const trpc = createTRPCNext({ * having a flash of content change whilst redirecting. **/ await opts.originalFn(); - await opts.queryClient.invalidateQueries(); + if (!opts.meta?.doNotInvalidate) { + await opts.queryClient.invalidateQueries(); + } }, }, },