Introduce favorite plugins
Summary: This diff lands improved sidebar navigation. The old functionality to order plugins based on last-recently-used, and cropping at 5 items has been removed. Instead, items can be starred and their position will be fixed. Together with the app switcher introduced this should lead to a cleaner, stabler, and more customizable UI. Reviewed By: jknoxville Differential Revision: D18299401 fbshipit-source-id: 29b7eb3a4130933c637f7c81834558bf738d5bf0
This commit is contained in:
committed by
Facebook Github Bot
parent
969a857fae
commit
3cee927674
@@ -22,7 +22,6 @@ import {registerPlugins} from './reducers/plugins';
|
||||
import createTableNativePlugin from './plugins/TableNativePlugin';
|
||||
import EventEmitter from 'events';
|
||||
import invariant from 'invariant';
|
||||
import {Responder} from 'rsocket-types/ReactiveSocketTypes';
|
||||
|
||||
type Plugins = Array<string>;
|
||||
|
||||
@@ -98,11 +97,6 @@ const handleError = (
|
||||
}
|
||||
};
|
||||
|
||||
export const MAX_MINIMUM_PLUGINS = 5;
|
||||
export const SHOW_REMAINING_PLUGIN_IF_LESS_THAN = 3;
|
||||
export const SAVED_PLUGINS_COUNT =
|
||||
MAX_MINIMUM_PLUGINS + SHOW_REMAINING_PLUGIN_IF_LESS_THAN;
|
||||
|
||||
export default class Client extends EventEmitter {
|
||||
app: App | undefined;
|
||||
connected: boolean;
|
||||
@@ -111,8 +105,6 @@ export default class Client extends EventEmitter {
|
||||
sdkVersion: number;
|
||||
messageIdCounter: number;
|
||||
plugins: Plugins;
|
||||
lessPlugins: Plugins | undefined;
|
||||
showAllPlugins: boolean;
|
||||
connection: RSocketClientSocket<any, any> | null | undefined;
|
||||
store: Store;
|
||||
activePlugins: Set<string>;
|
||||
@@ -146,7 +138,6 @@ export default class Client extends EventEmitter {
|
||||
super();
|
||||
this.connected = true;
|
||||
this.plugins = plugins ? plugins : [];
|
||||
this.showAllPlugins = false;
|
||||
this.connection = conn;
|
||||
this.id = id;
|
||||
this.query = query;
|
||||
@@ -188,29 +179,6 @@ export default class Client extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
/// Sort plugins by LRU order stored in lessPlugins; if not, sort by alphabet
|
||||
byClientLRU(
|
||||
pluginsCount: number,
|
||||
a: typeof FlipperPlugin,
|
||||
b: typeof FlipperPlugin,
|
||||
): number {
|
||||
// Sanity check
|
||||
if (this.lessPlugins != null) {
|
||||
const showPluginsCount =
|
||||
pluginsCount >= MAX_MINIMUM_PLUGINS + SHOW_REMAINING_PLUGIN_IF_LESS_THAN
|
||||
? MAX_MINIMUM_PLUGINS
|
||||
: pluginsCount;
|
||||
let idxA = this.lessPlugins.indexOf(a.id);
|
||||
idxA = idxA < 0 || idxA >= showPluginsCount ? showPluginsCount : idxA;
|
||||
let idxB = this.lessPlugins.indexOf(b.id);
|
||||
idxB = idxB < 0 || idxB >= showPluginsCount ? showPluginsCount : idxB;
|
||||
if (idxA !== idxB) {
|
||||
return idxA > idxB ? 1 : -1;
|
||||
}
|
||||
}
|
||||
return (a.title || a.id) > (b.title || b.id) ? 1 : -1;
|
||||
}
|
||||
|
||||
/* All clients should have a corresponding Device in the store.
|
||||
However, clients can connect before a device is registered, so wait a
|
||||
while for the device to be registered if it isn't already. */
|
||||
|
||||
Reference in New Issue
Block a user