update FDISK sync
This commit is contained in:
@@ -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'],
|
||||
|
||||
Reference in New Issue
Block a user