From e0e0a8f916e814b1b2e100ea88c79d63b4b196c6 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Thu, 10 Oct 2019 08:21:10 -0700 Subject: [PATCH] Add device argument in the constructor of Client Summary: Property `device` on Clients for archived device never resolve. As it gets resolved when `addConnection` is called which happens for real non-offline devices. To get around this, I have added an argument to the constructor of the Client, as for offline case we can construct the device before client and can pass it as an argument. Reviewed By: jknoxville Differential Revision: D17831261 fbshipit-source-id: a14fb0b65343cccac731077e983026388611d323 --- src/Client.tsx | 9 ++++++--- src/utils/exportData.tsx | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Client.tsx b/src/Client.tsx index 3feaec860..e719c205b 100644 --- a/src/Client.tsx +++ b/src/Client.tsx @@ -139,6 +139,7 @@ export default class Client extends EventEmitter { logger: Logger, store: Store, plugins?: Plugins | null | undefined, + device?: BaseDevice, ) { super(); this.connected = true; @@ -156,9 +157,11 @@ export default class Client extends EventEmitter { this.activePlugins = new Set(); this.lastSeenDeviceList = []; - this.device = new Promise((resolve, _reject) => { - this._deviceResolve = resolve; - }); + this.device = device + ? Promise.resolve(device) + : new Promise((resolve, _reject) => { + this._deviceResolve = resolve; + }); const client = this; // node.js doesn't support requestIdleCallback diff --git a/src/utils/exportData.tsx b/src/utils/exportData.tsx index 14dafaa89..c2e691430 100644 --- a/src/utils/exportData.tsx +++ b/src/utils/exportData.tsx @@ -612,6 +612,7 @@ export function importDataToStore(data: string, store: Store) { getLogger(), store, clientPlugins, + archivedDevice, ), }); });