Skip to content

Commit

Permalink
tweak stagger
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Nov 21, 2024
1 parent e85a70c commit 1a6227b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 2 additions & 0 deletions next-canary/src/app/ThemeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export function ThemeButton({tags}: {tags: SyncTag[]}) {
onClick={() =>
startTransition(async () => {
await randomColorTheme(tags)
// Wait 2 seconds to stagger requests a little bit
await new Promise((resolve) => setTimeout(resolve, 2_000))
})
}
className={`bg-theme-button text-theme-button focus:ring-theme focus:ring-offset-theme rounded-md px-4 py-2 text-sm font-semibold transition ease-in-out focus:outline-none focus:ring-2 focus:ring-opacity-50 focus:ring-offset-2 focus:duration-0 disabled:cursor-not-allowed disabled:opacity-50 ${pending ? 'animate-pulse cursor-wait duration-150' : 'duration-1000'} `}
Expand Down
2 changes: 0 additions & 2 deletions next-canary/src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export async function randomColorTheme(tags: SyncTag[]) {
const res = await fetch('https://lcapi-examples-api.sanity.dev/api/random-color-theme', {
method: 'PUT',
})
// Wait 5 seconds to stagger requests a little bit
await new Promise((resolve) => setTimeout(resolve, 5_000))
expireTag(...tags)
return res.json()
}

0 comments on commit 1a6227b

Please sign in to comment.