Select new client after connecting, if possible
Summary: Small UX improvement, try to select a newly arriving client if possible, this is nice as it means that disconnecting and connecting will typically end you up in the same app. Changelog: If a new client connects, Flipper will try to focus on it Reviewed By: nikoant Differential Revision: D26250896 fbshipit-source-id: 83d9777a8608cd887d663a6bbe1444d2aa614e95
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ff7997b3fa
commit
2df117923c
@@ -15,6 +15,7 @@ import Client from '../Client';
|
|||||||
import {UninitializedClient} from '../UninitializedClient';
|
import {UninitializedClient} from '../UninitializedClient';
|
||||||
import {addErrorNotification} from '../reducers/notifications';
|
import {addErrorNotification} from '../reducers/notifications';
|
||||||
import {CertificateExchangeMedium} from '../utils/CertificateProvider';
|
import {CertificateExchangeMedium} from '../utils/CertificateProvider';
|
||||||
|
import {selectClient, selectDevice} from '../reducers/connections';
|
||||||
|
|
||||||
export default (store: Store, logger: Logger) => {
|
export default (store: Store, logger: Logger) => {
|
||||||
const server = new Server(logger, store);
|
const server = new Server(logger, store);
|
||||||
@@ -96,9 +97,8 @@ export default (store: Store, logger: Logger) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function registerNewClient(store: Store, client: Client) {
|
export function registerNewClient(store: Store, client: Client) {
|
||||||
const existingClient = store
|
const {connections} = store.getState();
|
||||||
.getState()
|
const existingClient = connections.clients.find((c) => c.id === client.id);
|
||||||
.connections.clients.find((c) => c.id === client.id);
|
|
||||||
|
|
||||||
if (existingClient) {
|
if (existingClient) {
|
||||||
existingClient.destroy();
|
existingClient.destroy();
|
||||||
@@ -119,4 +119,21 @@ export function registerNewClient(store: Store, client: Client) {
|
|||||||
type: 'NEW_CLIENT',
|
type: 'NEW_CLIENT',
|
||||||
payload: client,
|
payload: client,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const device = client.deviceSync;
|
||||||
|
if (device) {
|
||||||
|
const selectedDevice = connections.selectedDevice;
|
||||||
|
const selectedClient = connections.clients.find(
|
||||||
|
(c) => c.id === connections.selectedApp,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
// If this condition meets, it means that the previous app wasn't selected explicitly by the user
|
||||||
|
connections.selectedApp !== connections.userPreferredApp ||
|
||||||
|
!selectedClient ||
|
||||||
|
!selectedDevice
|
||||||
|
) {
|
||||||
|
store.dispatch(selectDevice(device));
|
||||||
|
store.dispatch(selectClient(client.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user