Addresses an issue with Flipper message identifier

Summary:
This change addresses a problem with using data.id straight into the if statement.

If `data.id` is not undefined but has a value of 0 then the expression evaluates to false.

Right now, that wasn't the intended usage.

Using this change to also export some types from Client.

Reviewed By: passy

Differential Revision: D30069746

fbshipit-source-id: 04a8d161efceadf7a38ee556be70c15b45c11056
This commit is contained in:
Lorenzo Blasa
2021-08-03 09:29:37 -07:00
committed by Facebook GitHub Bot
parent 6791b29e45
commit b76ce357eb
2 changed files with 7 additions and 3 deletions

View File

@@ -54,12 +54,16 @@ export type ClientExport = {
query: ClientQuery;
};
type Params = {
export type Params = {
api: string;
method: string;
params?: Object;
};
type RequestMetadata = {method: string; id: number; params: Params | undefined};
export type RequestMetadata = {
method: string;
id: number;
params: Params | undefined;
};
const handleError = (store: Store, device: BaseDevice, error: ErrorType) => {
if (store.getState().settingsState.suppressPluginErrors) {

View File

@@ -133,7 +133,7 @@ class ServerWebSocket extends ServerWebSocketBase {
error?: ErrorType | undefined;
} = json;
if (data.hasOwnProperty('id') && data.id) {
if (data.hasOwnProperty('id') && data.id !== undefined) {
const callbacks = pendingRequests.get(data.id);
if (!callbacks) {
return;