Make plugin preference global
Summary: This is a change which I am not fully confident in, but I think it will make things better; previously favorite plugins where stored per device. This means that when ... - switching between devices - switching between apps - when viewing disconnected devices - when loading devices from flipper traces ... the starred plugin preference would reset (especially for the last two: they have generated unique device names, so there would never be preferred items) This Diff changes the plugin preferences to be global, so on every app and every device you have the same preferences (if they support the plugin). This assumes most people work mostly with the same limited set of plugins Reviewed By: jknoxville Differential Revision: D18780965 fbshipit-source-id: 3a560393b81e7d65ae01fb737938f8562843af13
This commit is contained in:
committed by
Facebook Github Bot
parent
c332f4145a
commit
35ddc25937
@@ -231,7 +231,7 @@ type StateFromProps = {
|
||||
staticView: StaticView;
|
||||
selectedPlugin: string | null | undefined;
|
||||
selectedApp: string | null | undefined;
|
||||
userStarredPlugins: Store['connections']['userStarredPlugins'];
|
||||
starredPlugins: Store['connections']['starredPlugins'];
|
||||
clients: Array<Client>;
|
||||
uninitializedClients: Array<{
|
||||
client: UninitializedClient;
|
||||
@@ -526,9 +526,8 @@ class MainSidebar extends PureComponent<Props, State> {
|
||||
(p: typeof FlipperPlugin) => client.plugins.indexOf(p.id) > -1,
|
||||
);
|
||||
const favoritePlugins: FlipperPlugins = getFavoritePlugins(
|
||||
client,
|
||||
allPlugins,
|
||||
this.props.userStarredPlugins,
|
||||
this.props.starredPlugins,
|
||||
true,
|
||||
);
|
||||
const showAllPlugins =
|
||||
@@ -585,9 +584,8 @@ class MainSidebar extends PureComponent<Props, State> {
|
||||
? this.renderPluginsByCategory(
|
||||
client,
|
||||
getFavoritePlugins(
|
||||
client,
|
||||
allPlugins,
|
||||
this.props.userStarredPlugins,
|
||||
this.props.starredPlugins,
|
||||
false,
|
||||
),
|
||||
false,
|
||||
@@ -601,16 +599,12 @@ class MainSidebar extends PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
function getFavoritePlugins(
|
||||
client: Client,
|
||||
allPlugins: FlipperPlugins,
|
||||
userStarredPlugins: Props['userStarredPlugins'],
|
||||
starredPlugins: Props['starredPlugins'],
|
||||
favorite: boolean,
|
||||
): FlipperPlugins {
|
||||
const appName = client.id;
|
||||
return allPlugins.filter(plugin => {
|
||||
const idx = userStarredPlugins[appName]
|
||||
? userStarredPlugins[appName].indexOf(plugin.id)
|
||||
: -1;
|
||||
const idx = starredPlugins.indexOf(plugin.id);
|
||||
return idx === -1 ? !favorite : favorite;
|
||||
});
|
||||
}
|
||||
@@ -639,7 +633,7 @@ export default connect<StateFromProps, DispatchFromProps, OwnProps, Store>(
|
||||
selectedDevice,
|
||||
selectedPlugin,
|
||||
selectedApp,
|
||||
userStarredPlugins,
|
||||
starredPlugins,
|
||||
clients,
|
||||
uninitializedClients,
|
||||
staticView,
|
||||
@@ -658,7 +652,7 @@ export default connect<StateFromProps, DispatchFromProps, OwnProps, Store>(
|
||||
staticView,
|
||||
selectedPlugin,
|
||||
selectedApp,
|
||||
userStarredPlugins,
|
||||
starredPlugins,
|
||||
clients,
|
||||
uninitializedClients,
|
||||
devicePlugins,
|
||||
|
||||
Reference in New Issue
Block a user