mirror of
https://github.com/langgenius/dify.git
synced 2026-03-01 05:48:40 +08:00
Eliminate useEffect-based synchronization of React Query server state into React Context, which caused extra renders, state drift, and incorrect loading/empty states on the /explore/apps page. - Remove installedApps, isFetchingInstalledApps, and controlUpdateInstalledApps from ExploreContext (dead code + anti-pattern) - Sidebar and InstalledApp now consume useGetInstalledApps() directly - Use isLoading (not isPending) for conditionally-enabled queries to avoid permanent loading state when query is disabled - Derive hasEditPermission during render instead of via useEffect - Replace FC type annotations with const arrow functions - Add return type to fetchInstalledAppList - Update all related unit and integration tests
25 lines
607 B
TypeScript
25 lines
607 B
TypeScript
import type { App } from '@/models/explore'
|
|
import { noop } from 'es-toolkit/function'
|
|
import { createContext } from 'use-context-selector'
|
|
|
|
export type CurrentTryAppParams = {
|
|
appId: string
|
|
app: App
|
|
}
|
|
|
|
export type IExplore = {
|
|
hasEditPermission: boolean
|
|
currentApp?: CurrentTryAppParams
|
|
isShowTryAppPanel: boolean
|
|
setShowTryAppPanel: (showTryAppPanel: boolean, params?: CurrentTryAppParams) => void
|
|
}
|
|
|
|
const ExploreContext = createContext<IExplore>({
|
|
hasEditPermission: false,
|
|
isShowTryAppPanel: false,
|
|
setShowTryAppPanel: noop,
|
|
currentApp: undefined,
|
|
})
|
|
|
|
export default ExploreContext
|