The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/views/admin/apps/AppsContext.tsx

31 lines
795 B

import { createContext, useContext } from 'react';
import { AsyncState, AsyncStatePhase } from '../../../lib/asyncState';
import { App } from './types';
type AppsContextValue = {
installedApps: AsyncState<{ apps: App[] }>;
marketplaceApps: AsyncState<{ apps: App[] }>;
reload: () => Promise<void>;
};
export const AppsContext = createContext<AppsContextValue>({
installedApps: {
phase: AsyncStatePhase.LOADING,
value: undefined,
error: undefined,
},
marketplaceApps: {
phase: AsyncStatePhase.LOADING,
value: undefined,
error: undefined,
},
reload: () => Promise.resolve(),
});
export const useAppsReload = (): (() => void) => {
const { reload } = useContext(AppsContext);
return reload;
};
export const useAppsResult = (): AppsContextValue => useContext(AppsContext);