mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 12:51:14 -05:00
Implement cache invalidation improvements
This commit is contained in:
@@ -13,9 +13,11 @@ import { Header } from '@/components/layout/Header';
|
||||
import { Footer } from '@/components/layout/Footer';
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle';
|
||||
import { useOpenGraph } from '@/hooks/useOpenGraph';
|
||||
import { useQueryInvalidation } from '@/lib/queryInvalidation';
|
||||
|
||||
export default function BlogPost() {
|
||||
const { slug } = useParams<{ slug: string }>();
|
||||
const { invalidateBlogPost } = useQueryInvalidation();
|
||||
|
||||
const { data: post, isLoading } = useBlogPost(slug);
|
||||
|
||||
@@ -34,9 +36,12 @@ export default function BlogPost() {
|
||||
|
||||
useEffect(() => {
|
||||
if (slug) {
|
||||
supabase.rpc('increment_blog_view_count', { post_slug: slug });
|
||||
supabase.rpc('increment_blog_view_count', { post_slug: slug }).then(() => {
|
||||
// Invalidate blog post cache to update view count
|
||||
invalidateBlogPost(slug);
|
||||
});
|
||||
}
|
||||
}, [slug]);
|
||||
}, [slug, invalidateBlogPost]);
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user