update FDISK sync

This commit is contained in:
Matthias Hochmeister
2026-03-13 08:46:12 +01:00
parent 243da302c7
commit 501b697ca2
4 changed files with 55 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
import React, { createContext, useContext, useState, useCallback, ReactNode } from 'react';
import { useQuery } from '@tanstack/react-query';
import React, { createContext, useContext, useState, useCallback, useEffect, useRef, ReactNode } from 'react';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { nextcloudApi } from '../services/nextcloud';
import { useLayout } from './LayoutContext';
import type { NextcloudConversation } from '../types/nextcloud.types';
@@ -21,6 +21,17 @@ interface ChatProviderProps {
export const ChatProvider: React.FC<ChatProviderProps> = ({ children }) => {
const [selectedRoomToken, setSelectedRoomToken] = useState<string | null>(null);
const { chatPanelOpen } = useLayout();
const queryClient = useQueryClient();
const prevPanelOpenRef = useRef(chatPanelOpen);
// Invalidate rooms/connection when panel opens so data is fresh immediately
useEffect(() => {
if (chatPanelOpen && !prevPanelOpenRef.current) {
queryClient.invalidateQueries({ queryKey: ['nextcloud', 'connection'] });
queryClient.invalidateQueries({ queryKey: ['nextcloud', 'rooms'] });
}
prevPanelOpenRef.current = chatPanelOpen;
}, [chatPanelOpen, queryClient]);
const { data: connData } = useQuery({
queryKey: ['nextcloud', 'connection'],