fix: invalidate properties cache after listing creation
Without this, navigating to Meine Inserate within 5 min of visiting it previously would show a stale empty list. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { useLocation, useNavigate } from 'react-router'
|
import { useLocation, useNavigate } from 'react-router'
|
||||||
|
import { useQueryClient } from '@tanstack/react-query'
|
||||||
import {
|
import {
|
||||||
Alert,
|
Alert,
|
||||||
Box,
|
Box,
|
||||||
@@ -76,6 +77,7 @@ interface LocationState {
|
|||||||
|
|
||||||
export default function NewListing() {
|
export default function NewListing() {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
const qc = useQueryClient()
|
||||||
const { state } = useLocation() as { state: LocationState | null }
|
const { state } = useLocation() as { state: LocationState | null }
|
||||||
const pre = state?.prefill ?? {}
|
const pre = state?.prefill ?? {}
|
||||||
|
|
||||||
@@ -219,6 +221,7 @@ export default function NewListing() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await propertyService.create(input)
|
await propertyService.create(input)
|
||||||
|
qc.invalidateQueries({ queryKey: ['properties'] })
|
||||||
setCreated(true)
|
setCreated(true)
|
||||||
} catch {
|
} catch {
|
||||||
setError('Fehler beim Erstellen des Inserats. Bitte erneut versuchen.')
|
setError('Fehler beim Erstellen des Inserats. Bitte erneut versuchen.')
|
||||||
|
|||||||
Reference in New Issue
Block a user