From 7513d36689db99ec6254a630ddf0b6454e3434fe Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 14 Jan 2020 09:15:46 -0800 Subject: [PATCH] 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 --- src/chrome/mainsidebar/MainSidebar2.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/chrome/mainsidebar/MainSidebar2.tsx b/src/chrome/mainsidebar/MainSidebar2.tsx index 2c824a0ef..ead31249a 100644 --- a/src/chrome/mainsidebar/MainSidebar2.tsx +++ b/src/chrome/mainsidebar/MainSidebar2.tsx @@ -34,6 +34,7 @@ import React, { memo, useCallback, useState, + useEffect, } from 'react'; import NotificationScreen from '../NotificationScreen'; import { @@ -451,6 +452,16 @@ const PluginList = memo(function PluginList({ selectPlugin: SelectPlugin; 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( (plugin: string) => { starPlugin({