fix(remote-control): always sync on session switch even if turn started
This commit is contained in:
parent
b77c2a57b0
commit
9821efa370
|
|
@ -30,16 +30,11 @@ const QRCode = _require("qrcode") as { toString: (text: string, opts: any) => Pr
|
||||||
export default function remoteControl(pi: ExtensionAPI) {
|
export default function remoteControl(pi: ExtensionAPI) {
|
||||||
let server: RemoteServer | undefined;
|
let server: RemoteServer | undefined;
|
||||||
let pendingSyncTimer: ReturnType<typeof setTimeout> | undefined;
|
let pendingSyncTimer: ReturnType<typeof setTimeout> | undefined;
|
||||||
let needsSyncOnIdle = false;
|
|
||||||
|
|
||||||
function scheduleSync(ctx: ExtensionContext): void {
|
function scheduleSync(ctx: ExtensionContext): void {
|
||||||
if (pendingSyncTimer) clearTimeout(pendingSyncTimer);
|
if (pendingSyncTimer) clearTimeout(pendingSyncTimer);
|
||||||
pendingSyncTimer = setTimeout(() => {
|
pendingSyncTimer = setTimeout(() => {
|
||||||
pendingSyncTimer = undefined;
|
pendingSyncTimer = undefined;
|
||||||
if (!ctx.isIdle()) {
|
|
||||||
needsSyncOnIdle = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
server?.sync(ctx);
|
server?.sync(ctx);
|
||||||
updateStatus(ctx);
|
updateStatus(ctx);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
@ -118,10 +113,6 @@ export default function remoteControl(pi: ExtensionAPI) {
|
||||||
|
|
||||||
pi.on("agent_end", async (_event, ctx) => {
|
pi.on("agent_end", async (_event, ctx) => {
|
||||||
server?.broadcast({ type: "agent_end" });
|
server?.broadcast({ type: "agent_end" });
|
||||||
if (needsSyncOnIdle) {
|
|
||||||
needsSyncOnIdle = false;
|
|
||||||
server?.sync(ctx);
|
|
||||||
}
|
|
||||||
updateStatus(ctx);
|
updateStatus(ctx);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue