Fix inconsistent handling of app id and name

Summary:
Changelog: Improved plugin / device / app selection handing.

During some refactorings I discovered that the `connetions.selectedApp` field contained sometimes an application id, and sometimes just the name. This caused inconsistent behavior especially in unit tests.

I've cleaned that up, and renamed it to `selectedAppId` where applicable, to make the distinction more clear.

And, in contrast, userPreferredApp now always has a name, not an id.

During refactoring our existing selection update logic was quite in the way, which was overcomplicated still, since during the sandy chrome migration, the reducers needed to be able to handle both the old UI, and the new application selection UI. That logic has been simplified now, and a lot of tests were added.

As a further simplification the preferredApp/Device/Plugin are now only read and used when updating selection, but not when running selectors.

Reviewed By: timur-valiev

Differential Revision: D31305180

fbshipit-source-id: 2dbd9f9c33950227cc63aa29cc4a98bdd0db8e7a
This commit is contained in:
Michel Weststrate
2021-10-04 07:26:11 -07:00
committed by Facebook GitHub Bot
parent ba89daf12c
commit c9a34d3cc2
30 changed files with 497 additions and 280 deletions

View File

@@ -173,11 +173,6 @@ export async function handleClientConnected(store: Store, client: Client) {
payload: client,
});
const device = client.device;
if (device) {
store.dispatch(selectDevice(device));
store.dispatch(selectClient(client.id));
}
store.dispatch(selectClient(client.id));
client.emit('plugins-change');
}