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
This commit is contained in:
Pritesh Nandgaonkar
2019-10-10 08:21:10 -07:00
committed by Facebook Github Bot
parent e31f526618
commit e0e0a8f916
2 changed files with 7 additions and 3 deletions

View File

@@ -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

View File

@@ -612,6 +612,7 @@ export function importDataToStore(data: string, store: Store) {
getLogger(),
store,
clientPlugins,
archivedDevice,
),
});
});