Skip to content

Commit 622fd53

Browse files
committed
chore: rename to resolveQueuedJob
1 parent 25a7c05 commit 622fd53

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

libs/ledger-live-common/src/deviceSDK/transports/core.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,13 @@ export const withTransport = (deviceId: string, options?: { openTimeoutMs?: numb
9696
};
9797

9898
// When we'll finish all the current job, we'll call finish
99-
// resolveQueuedJob
100-
let resolveQueuedDevice;
99+
let resolveQueuedJob;
101100

102101
// Queue of linked Promises that wait after each other
103102
// Blocking any future job on this device
104103
deviceQueues[deviceId] = {
105104
job: new Promise(resolve => {
106-
resolveQueuedDevice = resolve;
105+
resolveQueuedJob = resolve;
107106
}),
108107
id: jobId,
109108
};
@@ -116,7 +115,7 @@ export const withTransport = (deviceId: string, options?: { openTimeoutMs?: numb
116115
if (unsubscribed) {
117116
tracer.trace("Unsubscribed (1) while processing job");
118117
// It was unsubscribed prematurely
119-
return finalize(transport, [resolveQueuedDevice]);
118+
return finalize(transport, [resolveQueuedJob]);
120119
}
121120

122121
if (needsCleanup[identifyTransport(transport)]) {
@@ -130,7 +129,7 @@ export const withTransport = (deviceId: string, options?: { openTimeoutMs?: numb
130129
// This catch is here only for errors that might happen at open or at clean up of the transport before doing the job
131130
const onErrorDuringTransportSetup = (error: unknown) => {
132131
tracer.trace("Error while setting up a transport: ", { error });
133-
resolveQueuedDevice();
132+
resolveQueuedJob();
134133
if (error instanceof BluetoothRequired) throw error;
135134
if (error instanceof TransportWebUSBGestureRequired) throw error;
136135
if (error instanceof TransportInterfaceNotAvailable) throw error;
@@ -204,15 +203,15 @@ export const withTransport = (deviceId: string, options?: { openTimeoutMs?: numb
204203
if (unsubscribed) {
205204
tracer.trace("Unsubscribed (2) while processing job");
206205
// It was unsubscribed prematurely
207-
return finalize(transportRef.current, [resolveQueuedDevice]);
206+
return finalize(transportRef.current, [resolveQueuedJob]);
208207
}
209208

210209
sub = job({ transportRef })
211210
.pipe(
212211
catchError(error => initialErrorRemapping(error, tracer.getContext())),
213212
catchError(errorRemapping), // close the transport and clean up everything
214213
transportFinally(() => {
215-
return finalize(transportRef.current, [resolveQueuedDevice]);
214+
return finalize(transportRef.current, [resolveQueuedJob]);
216215
}),
217216
)
218217
.subscribe(subscriber);

libs/ledger-live-common/src/hw/deviceAccess.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,13 @@ export const withDevice =
142142
};
143143

144144
// When we'll finish all the current job, we'll call finish
145-
// notifyJobCompleted ? resolveCurrentJob
146-
let resolveQueuedDevice;
145+
let resolveQueuedJob;
147146

148147
// Queue of linked Promises that wait after each other
149148
// Blocking any future job on this device
150149
deviceQueues[deviceId] = {
151150
job: new Promise(resolve => {
152-
resolveQueuedDevice = resolve;
151+
resolveQueuedJob = resolve;
153152
}),
154153
id: jobId,
155154
};
@@ -172,7 +171,7 @@ export const withDevice =
172171
if (unsubscribed) {
173172
tracer.trace("Unsubscribed (1) while processing job");
174173
// It was unsubscribed prematurely
175-
return finalize(transport, [resolveQueuedDevice]);
174+
return finalize(transport, [resolveQueuedJob]);
176175
}
177176
setAllowAutoDisconnect(transport, deviceId, false);
178177

@@ -186,7 +185,7 @@ export const withDevice =
186185
// This catch is here only for errors that might happen at open or at clean up of the transport before doing the job
187186
.catch(e => {
188187
tracer.trace("Error while opening Transport: ", { e });
189-
resolveQueuedDevice();
188+
resolveQueuedJob();
190189
if (e instanceof BluetoothRequired) throw e;
191190
if (e instanceof TransportWebUSBGestureRequired) throw e;
192191
if (e instanceof TransportInterfaceNotAvailable) throw e;
@@ -202,7 +201,7 @@ export const withDevice =
202201
// It was unsubscribed prematurely
203202
if (unsubscribed) {
204203
tracer.trace("Unsubscribed (2) while processing job");
205-
return finalize(transport, [resolveQueuedDevice]);
204+
return finalize(transport, [resolveQueuedJob]);
206205
}
207206

208207
sub = job(transport)
@@ -211,7 +210,7 @@ export const withDevice =
211210
catchError(errorRemapping),
212211
transportFinally(() => {
213212
// Closes the transport and cleans up everything
214-
return finalize(transport, [resolveQueuedDevice]);
213+
return finalize(transport, [resolveQueuedJob]);
215214
}),
216215
)
217216
.subscribe({

0 commit comments

Comments
 (0)