Something went wrong. Try again.
ATProto-based AI Assistant Chat interface.
Something went wrong. Try again.
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import { useQueryClient } from '@tanstack/react-query'import { attachmentTypesQuery } from '../../conversation/attachment-types.ts'import { modelsQuery } from '../../models/queries.ts'import { pluginSettingsQuery, providersQuery } from '../../settings/queries.ts'import { adminModelsQuery, adminPluginsQuery, adminRolesQuery, adminUsersKey } from '../queries.ts'
/** * Refresh what a plugin change can alter. Each change rebuilds the server's plugins, which decide * the admin models' warnings and, for this admin as a user, their models, providers, plugin * settings, and attachment types. */export function usePluginsChanged() { const queryClient = useQueryClient() return () => Promise.all( [ adminPluginsQuery, adminModelsQuery, modelsQuery, providersQuery, pluginSettingsQuery, attachmentTypesQuery, ].map(({ queryKey }) => queryClient.invalidateQueries({ queryKey })), )}
/** Refresh the admin models, and the model list they add to for every user, this admin included. */export function useModelsChanged() { const queryClient = useQueryClient() return () => Promise.all( [adminModelsQuery, modelsQuery].map(({ queryKey }) => queryClient.invalidateQueries({ queryKey }), ), )}
/** Refresh the roles, and the users, since each user lists their roles and a role its members. */export function useRolesChanged() { const queryClient = useQueryClient() return () => Promise.all([ queryClient.invalidateQueries({ queryKey: adminRolesQuery.queryKey }), queryClient.invalidateQueries({ queryKey: adminUsersKey }), ])}
/** Refresh every users search. */export function useUsersChanged() { const queryClient = useQueryClient() return () => queryClient.invalidateQueries({ queryKey: adminUsersKey })}