Skip to content

Commit

Permalink
replace revalidation helper with revalidate path
Browse files Browse the repository at this point in the history
  • Loading branch information
Salief authored and Salief committed Jun 1, 2024
1 parent 9c1549b commit 477e62b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 25 deletions.
4 changes: 2 additions & 2 deletions apps/site/components/client/EditUsernameDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion apps/site/lib/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './getItemsWithUserId'
export * from './revalidationHelper'
10 changes: 0 additions & 10 deletions apps/site/lib/actions/revalidationHelper.ts

This file was deleted.

5 changes: 2 additions & 3 deletions apps/site/lib/posts/processBatchCreateAddItemPost.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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,
Expand Down Expand Up @@ -130,7 +130,6 @@ export async function processBatchCreateAddItemPost({

if (txnInclusion) {
revalidatePath('/', 'layout')
// revalidationHelper('/', 'layout')
return true
} else {
console.error('Transaction was not successfully included.')
Expand Down
7 changes: 4 additions & 3 deletions apps/site/lib/posts/processBatchMoveItemPost.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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.')
Expand Down
5 changes: 3 additions & 2 deletions apps/site/lib/posts/processCreateChannelPost.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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.')
Expand Down
5 changes: 3 additions & 2 deletions apps/site/lib/posts/processEditRolesPost.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -9,6 +9,7 @@ import {
remove0xPrefix,
} from 'scrypt'
import type { Hash, Hex } from 'viem'
import { revalidatePath } from 'next/cache'

export async function processEditRolesPost({
rid,
Expand Down Expand Up @@ -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.')
Expand Down
5 changes: 3 additions & 2 deletions apps/site/lib/posts/processRemoveItemPost.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -8,6 +8,7 @@ import {
remove0xPrefix,
} from 'scrypt'
import type { Hash, Hex } from 'viem'
import { revalidatePath } from 'next/cache'

export async function processRemoveItemPost({
signer,
Expand Down Expand Up @@ -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.')
Expand Down

0 comments on commit 477e62b

Please sign in to comment.