Refactor installed plugin props passing
Summary: Left this out from diff at the bottom of the stack to keep it a bit smaller. Reviewed By: jknoxville Differential Revision: D18272165 fbshipit-source-id: a2b0826e268b737341e2ef1c0f96dde32491237f
This commit is contained in:
committed by
Facebook Github Bot
parent
d2dfb924fd
commit
9bb0dad5d6
@@ -126,8 +126,7 @@ const PluginInstaller = function props(props: Props) {
|
|||||||
query,
|
query,
|
||||||
setQuery,
|
setQuery,
|
||||||
props.searchIndexFactory,
|
props.searchIndexFactory,
|
||||||
// TODO(T56693735): Refactor this to directly take props.
|
props.installedPlugins,
|
||||||
async () => props.installedPlugins,
|
|
||||||
props.refreshInstalledPlugins,
|
props.refreshInstalledPlugins,
|
||||||
);
|
);
|
||||||
const restartApp = useCallback(() => {
|
const restartApp = useCallback(() => {
|
||||||
@@ -294,28 +293,17 @@ function useNPMSearch(
|
|||||||
query: string,
|
query: string,
|
||||||
setQuery: (query: string) => void,
|
setQuery: (query: string) => void,
|
||||||
searchClientFactory: () => algoliasearch.Index,
|
searchClientFactory: () => algoliasearch.Index,
|
||||||
getInstalledPlugins: () => Promise<Map<string, PluginDefinition>>,
|
installedPlugins: Map<string, PluginDefinition>,
|
||||||
refreshInstalledPlugins: () => void,
|
refreshInstalledPlugins: () => void,
|
||||||
): TableRows_immutable {
|
): TableRows_immutable {
|
||||||
const index = useMemo(searchClientFactory, []);
|
const index = useMemo(searchClientFactory, []);
|
||||||
const [installedPlugins, setInstalledPlugins] = useState(
|
|
||||||
new Map<string, PluginDefinition>(),
|
|
||||||
);
|
|
||||||
|
|
||||||
const getAndSetInstalledPlugins = () =>
|
|
||||||
reportPlatformFailures(
|
|
||||||
getInstalledPlugins(),
|
|
||||||
`${TAG}:getInstalledPlugins`,
|
|
||||||
).then(setInstalledPlugins);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
reportUsage(`${TAG}:open`);
|
reportUsage(`${TAG}:open`);
|
||||||
getAndSetInstalledPlugins();
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onInstall = useCallback(async () => {
|
const onInstall = useCallback(async () => {
|
||||||
refreshInstalledPlugins();
|
refreshInstalledPlugins();
|
||||||
getAndSetInstalledPlugins();
|
|
||||||
setRestartRequired(true);
|
setRestartRequired(true);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user