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:
committed by
Facebook Github Bot
parent
e31f526618
commit
e0e0a8f916
@@ -139,6 +139,7 @@ export default class Client extends EventEmitter {
|
|||||||
logger: Logger,
|
logger: Logger,
|
||||||
store: Store,
|
store: Store,
|
||||||
plugins?: Plugins | null | undefined,
|
plugins?: Plugins | null | undefined,
|
||||||
|
device?: BaseDevice,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.connected = true;
|
this.connected = true;
|
||||||
@@ -156,9 +157,11 @@ export default class Client extends EventEmitter {
|
|||||||
this.activePlugins = new Set();
|
this.activePlugins = new Set();
|
||||||
this.lastSeenDeviceList = [];
|
this.lastSeenDeviceList = [];
|
||||||
|
|
||||||
this.device = new Promise((resolve, _reject) => {
|
this.device = device
|
||||||
this._deviceResolve = resolve;
|
? Promise.resolve(device)
|
||||||
});
|
: new Promise((resolve, _reject) => {
|
||||||
|
this._deviceResolve = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
const client = this;
|
const client = this;
|
||||||
// node.js doesn't support requestIdleCallback
|
// node.js doesn't support requestIdleCallback
|
||||||
|
|||||||
@@ -612,6 +612,7 @@ export function importDataToStore(data: string, store: Store) {
|
|||||||
getLogger(),
|
getLogger(),
|
||||||
store,
|
store,
|
||||||
clientPlugins,
|
clientPlugins,
|
||||||
|
archivedDevice,
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user