From 477e62bd37ef56fafecf72f347b95db317b4065e Mon Sep 17 00:00:00 2001 From: Salief Date: Sat, 1 Jun 2024 14:53:14 -0400 Subject: [PATCH] replace revalidation helper with revalidate path --- apps/site/components/client/EditUsernameDialog.tsx | 4 ++-- apps/site/lib/actions/index.ts | 1 - apps/site/lib/actions/revalidationHelper.ts | 10 ---------- apps/site/lib/posts/processBatchCreateAddItemPost.ts | 5 ++--- apps/site/lib/posts/processBatchMoveItemPost.ts | 7 ++++--- apps/site/lib/posts/processCreateChannelPost.ts | 5 +++-- apps/site/lib/posts/processEditRolesPost.ts | 5 +++-- apps/site/lib/posts/processRemoveItemPost.ts | 5 +++-- 8 files changed, 17 insertions(+), 25 deletions(-) delete mode 100644 apps/site/lib/actions/revalidationHelper.ts diff --git a/apps/site/components/client/EditUsernameDialog.tsx b/apps/site/components/client/EditUsernameDialog.tsx index 97f6e0a33..e50bbac01 100644 --- a/apps/site/components/client/EditUsernameDialog.tsx +++ b/apps/site/components/client/EditUsernameDialog.tsx @@ -39,8 +39,8 @@ import { custom, } from 'viem' import { optimism } from 'viem/chains' -import { revalidationHelper } from '@/lib' import { useRouter } from 'next/navigation' +import { revalidatePath } from 'next/cache' interface UsernameDialogProps { open: boolean @@ -142,7 +142,7 @@ export function EditUsernameDialog({ open, setOpen }: UsernameDialogProps) { }) if (resp.success) { success = true - revalidationHelper('/', 'layout') + revalidatePath('/', 'layout') router.push(`/${form.getValues().username}`) } // reset context embeddedWallet + userId + username diff --git a/apps/site/lib/actions/index.ts b/apps/site/lib/actions/index.ts index a474919aa..de4b704f9 100644 --- a/apps/site/lib/actions/index.ts +++ b/apps/site/lib/actions/index.ts @@ -1,2 +1 @@ export * from './getItemsWithUserId' -export * from './revalidationHelper' diff --git a/apps/site/lib/actions/revalidationHelper.ts b/apps/site/lib/actions/revalidationHelper.ts deleted file mode 100644 index 09c67dbe2..000000000 --- a/apps/site/lib/actions/revalidationHelper.ts +++ /dev/null @@ -1,10 +0,0 @@ -'use server' - -import { revalidatePath } from 'next/cache' - -export async function revalidationHelper( - path: string, - type?: 'page' | 'layout', -) { - revalidatePath(path, type) -} diff --git a/apps/site/lib/posts/processBatchCreateAddItemPost.ts b/apps/site/lib/posts/processBatchCreateAddItemPost.ts index a52a8826c..2e396dd53 100644 --- a/apps/site/lib/posts/processBatchCreateAddItemPost.ts +++ b/apps/site/lib/posts/processBatchCreateAddItemPost.ts @@ -1,5 +1,4 @@ -import { getTxnInclusion, relayPostBatch, revalidationHelper } from '@/lib' -import { revalidatePath } from 'next/cache' +import { getTxnInclusion, relayPostBatch } from '@/lib' import { messageToCid } from '@/utils' import type { SignMessageModalUIOptions } from '@privy-io/react-auth' import { @@ -11,6 +10,7 @@ import { remove0xPrefix, } from 'scrypt' import { type Hash, type Hex, encodeAbiParameters } from 'viem' +import { revalidatePath } from 'next/cache' export async function processBatchCreateAddItemPost({ signer, @@ -130,7 +130,6 @@ export async function processBatchCreateAddItemPost({ if (txnInclusion) { revalidatePath('/', 'layout') - // revalidationHelper('/', 'layout') return true } else { console.error('Transaction was not successfully included.') diff --git a/apps/site/lib/posts/processBatchMoveItemPost.ts b/apps/site/lib/posts/processBatchMoveItemPost.ts index 30731a942..2de3b5ab1 100644 --- a/apps/site/lib/posts/processBatchMoveItemPost.ts +++ b/apps/site/lib/posts/processBatchMoveItemPost.ts @@ -1,4 +1,4 @@ -import { getTxnInclusion, relayPostBatch, revalidationHelper } from '@/lib' +import { getTxnInclusion, relayPostBatch } from '@/lib' import type { SignMessageModalUIOptions } from '@privy-io/react-auth' import { type Post, @@ -8,7 +8,8 @@ import { getExpiration, remove0xPrefix, } from 'scrypt' -import { type Hash, type Hex, encodeAbiParameters } from 'viem' +import { type Hash, type Hex } from 'viem' +import { revalidatePath } from 'next/cache' type Diff = { channelId: string @@ -111,7 +112,7 @@ export async function processBatchMoveItemPost({ const txnInclusion = await getTxnInclusion(transactionHash) if (txnInclusion) { - revalidationHelper('/', 'layout') + revalidatePath('/', 'layout') return true } else { console.error('Transaction was not successfully included.') diff --git a/apps/site/lib/posts/processCreateChannelPost.ts b/apps/site/lib/posts/processCreateChannelPost.ts index 15a5401e4..f5edfdd43 100644 --- a/apps/site/lib/posts/processCreateChannelPost.ts +++ b/apps/site/lib/posts/processCreateChannelPost.ts @@ -1,5 +1,5 @@ import { relayPost } from '@/lib' -import { getTxnInclusion, revalidationHelper } from '@/lib' +import { getTxnInclusion } from '@/lib' import type { SignMessageModalUIOptions } from '@privy-io/react-auth' import { encodeCreateChannelMsgBody, @@ -9,6 +9,7 @@ import { } from 'scrypt' import type { Hash, Hex } from 'viem' import { messageToCid } from '@/utils' +import { revalidatePath } from 'next/cache' export async function processCreateChannelPost({ signer, @@ -72,7 +73,7 @@ export async function processCreateChannelPost({ const txnInclusion = await getTxnInclusion(transactionHash) if (txnInclusion) { - revalidationHelper('/', 'layout') + revalidatePath('/', 'layout') return { success: true, channelId: channelCid } } else { console.error('Transaction was not successfully included.') diff --git a/apps/site/lib/posts/processEditRolesPost.ts b/apps/site/lib/posts/processEditRolesPost.ts index 24a34edc6..0740f9a35 100644 --- a/apps/site/lib/posts/processEditRolesPost.ts +++ b/apps/site/lib/posts/processEditRolesPost.ts @@ -1,5 +1,5 @@ import { relayPost } from '@/lib' -import { getTxnInclusion, revalidationHelper } from '@/lib' +import { getTxnInclusion } from '@/lib' import type { SignMessageModalUIOptions } from '@privy-io/react-auth' import { MessageTypes, @@ -9,6 +9,7 @@ import { remove0xPrefix, } from 'scrypt' import type { Hash, Hex } from 'viem' +import { revalidatePath } from 'next/cache' export async function processEditRolesPost({ rid, @@ -70,7 +71,7 @@ export async function processEditRolesPost({ const txnInclusion = await getTxnInclusion(transactionHash) if (txnInclusion) { - revalidationHelper('/', 'layout') + revalidatePath('/', 'layout') return true } else { console.error('Transaction was not successfully included.') diff --git a/apps/site/lib/posts/processRemoveItemPost.ts b/apps/site/lib/posts/processRemoveItemPost.ts index 7f1d9695e..21423b434 100644 --- a/apps/site/lib/posts/processRemoveItemPost.ts +++ b/apps/site/lib/posts/processRemoveItemPost.ts @@ -1,5 +1,5 @@ import { relayPost } from '@/lib' -import { getTxnInclusion, revalidationHelper } from '@/lib' +import { getTxnInclusion } from '@/lib' import type { SignMessageModalUIOptions } from '@privy-io/react-auth' import { encodeRemoveItemMsgBody, @@ -8,6 +8,7 @@ import { remove0xPrefix, } from 'scrypt' import type { Hash, Hex } from 'viem' +import { revalidatePath } from 'next/cache' export async function processRemoveItemPost({ signer, @@ -66,7 +67,7 @@ export async function processRemoveItemPost({ const txnInclusion = await getTxnInclusion(transactionHash) if (txnInclusion) { - revalidationHelper('/', 'layout') + revalidatePath('/', 'layout') return true } else { console.error('Transaction was not successfully included.')