From b76ce357ebc9e12666b7ddb57bb2eb6c31446e7d Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Tue, 3 Aug 2021 09:29:37 -0700 Subject: [PATCH] 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 --- desktop/app/src/Client.tsx | 8 ++++++-- desktop/app/src/comms/ServerWebSocket.tsx | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/desktop/app/src/Client.tsx b/desktop/app/src/Client.tsx index 8a70f18ac..4da625bde 100644 --- a/desktop/app/src/Client.tsx +++ b/desktop/app/src/Client.tsx @@ -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) { diff --git a/desktop/app/src/comms/ServerWebSocket.tsx b/desktop/app/src/comms/ServerWebSocket.tsx index 840ccee46..83451d242 100644 --- a/desktop/app/src/comms/ServerWebSocket.tsx +++ b/desktop/app/src/comms/ServerWebSocket.tsx @@ -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;