import { ChatConverseInfo , fetchConverseInfo } from '../model/converse' ; import { findGroupInviteByCode , GroupInvite } from '../model/group' ; import { fetchLocalStaticRegistryPlugins , fetchRegistryPlugins , fetchServiceRegistryPlugins , PluginManifest , } from '../model/plugin' ; import { fetchUserInfo , UserBaseInfo } from '../model/user' ; import { queryClient } from './index' ; /**
 * 获取缓存的用户信息
 */ export async function getCachedUserInfo ( userId , refetch = false ) { const data = await queryClient . fetchQuery ( [ 'user' , userId ] , ( ) => fetchUserInfo ( userId ) , { staleTime : refetch ? 0 : 2 * 60 * 60 * 1000 } ) ; return data ; } /**
 * 获取缓存的会话信息
 */ export async function getCachedConverseInfo ( converseId ) { const data = await queryClient . fetchQuery ( [ 'converse' , converseId ] , ( ) => fetchConverseInfo ( converseId ) ) ; return data ; } /**
 * 获取缓存的邀请码信息
 */ export async function getCachedGroupInviteInfo ( inviteCode ) { const data = await queryClient . fetchQuery ( [ 'groupInvite' , inviteCode ] , ( ) => findGroupInviteByCode ( inviteCode ) ) ; return data ; } /**
 * 获取缓存的插件列表
 */ export async function getCachedRegistryPlugins ( ) { const data = await queryClient . fetchQuery ( [ 'pluginRegistry' ] , ( ) => Promise . all ( [ fetchRegistryPlugins ( ) . catch ( ( ) => [ ] ) , fetchServiceRegistryPlugins ( ) . catch ( ( ) => [ ] ) , fetchLocalStaticRegistryPlugins ( ) . catch ( ( ) => [ ] ) , ] ) . then ( ( [ a , b , c ] ) => [ ... a , ... b , ... c ] ) , { staleTime : 2 * 60 * 60 * 1000 } ) ; return data ; }