Make sure sidebar detects fresh plugins
Summary: New plugins are not detected because the available plugins are stored in the mutable Client class, so we have to subscribe to the event emitter Reviewed By: passy Differential Revision: D19347654 fbshipit-source-id: 68af63bf9bbe6319b2994dc8d07ca5eb27bb33b4
This commit is contained in:
committed by
Facebook Github Bot
parent
f06c8b8db2
commit
7513d36689
@@ -34,6 +34,7 @@ import React, {
|
|||||||
memo,
|
memo,
|
||||||
useCallback,
|
useCallback,
|
||||||
useState,
|
useState,
|
||||||
|
useEffect,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import NotificationScreen from '../NotificationScreen';
|
import NotificationScreen from '../NotificationScreen';
|
||||||
import {
|
import {
|
||||||
@@ -451,6 +452,16 @@ const PluginList = memo(function PluginList({
|
|||||||
selectPlugin: SelectPlugin;
|
selectPlugin: SelectPlugin;
|
||||||
selectedApp?: null | string;
|
selectedApp?: null | string;
|
||||||
}) {
|
}) {
|
||||||
|
// client is a mutable structure, so we need the event emitter to detect the addition of plugins....
|
||||||
|
const [_, setPluginsChanged] = useState(0);
|
||||||
|
useEffect(() => {
|
||||||
|
const listener = () => setPluginsChanged(v => v + 1);
|
||||||
|
client.on('plugins-change', listener);
|
||||||
|
return () => {
|
||||||
|
client.off('plugins-change', listener);
|
||||||
|
};
|
||||||
|
}, [client]);
|
||||||
|
|
||||||
const onFavorite = useCallback(
|
const onFavorite = useCallback(
|
||||||
(plugin: string) => {
|
(plugin: string) => {
|
||||||
starPlugin({
|
starPlugin({
|
||||||
|
|||||||
Reference in New Issue
Block a user