fix(k1): stabilize live recovery and media admission
This commit is contained in:
@@ -1875,6 +1875,20 @@ function invokeState(actionId: string, input: object = {}): Promise<XgridsK1Stat
|
||||
);
|
||||
}
|
||||
|
||||
let stateReadInFlight: Promise<XgridsK1State> | null = null;
|
||||
|
||||
function readStateSingleFlight(): Promise<XgridsK1State> {
|
||||
if (stateReadInFlight) return stateReadInFlight;
|
||||
|
||||
const request = invokeState(xgridsK1Actions.stateRead);
|
||||
stateReadInFlight = request;
|
||||
const release = () => {
|
||||
if (stateReadInFlight === request) stateReadInFlight = null;
|
||||
};
|
||||
void request.then(release, release);
|
||||
return request;
|
||||
}
|
||||
|
||||
export const xgridsK1Api = {
|
||||
async getHealth(): Promise<HealthResponse> {
|
||||
const payload = await requestJson(
|
||||
@@ -1890,7 +1904,7 @@ export const xgridsK1Api = {
|
||||
},
|
||||
|
||||
async getState(): Promise<XgridsK1State> {
|
||||
return invokeState(xgridsK1Actions.stateRead);
|
||||
return readStateSingleFlight();
|
||||
},
|
||||
|
||||
scanBle(
|
||||
|
||||
Reference in New Issue
Block a user