fix(junction): make complex corner radius responsive
This commit is contained in:
1 parent
36a8291c05
commit
53a2cb3450
8 files changed
+103
-11
No files matched your search
@@ -24,6 +24,8 @@ export type PreviewDraft = Pick<EditPreviewRequest, 'constraints' | 'operations'
|
||||
export interface PreviewRequesterOptions {
|
||||
session: EditSession;
|
||||
send: PreviewTransport;
|
||||
/** True from the first queued draft until its latest request has settled. */
|
||||
onPendingChange?: (pending: boolean) => void;
|
||||
/** Called for every response the session accepted, stale ones excluded. */
|
||||
onSettled: (outcome: PreviewOutcome, response: EditPreviewResponse) => void;
|
||||
/** Real failures only; an abort is expected and never reported. */
|
||||
@@ -40,6 +42,7 @@ export class PreviewRequester {
|
||||
private inFlight: AbortController | null = null;
|
||||
/** Changes whenever the owning map/junction scope changes. */
|
||||
private generation = 0;
|
||||
private pending = false;
|
||||
private readonly debounceMs: number;
|
||||
|
||||
constructor(private readonly options: PreviewRequesterOptions) {
|
||||
@@ -48,6 +51,7 @@ export class PreviewRequester {
|
||||
|
||||
/** During a drag: coalesce to one request per debounce window. */
|
||||
schedule(draft: PreviewDraft): void {
|
||||
this.setPending(true);
|
||||
if (this.timer) clearTimeout(this.timer);
|
||||
this.timer = setTimeout(() => {
|
||||
this.timer = null;
|
||||
@@ -60,6 +64,7 @@ export class PreviewRequester {
|
||||
* meant, so it must not be dropped by a pending timer or lost to the debounce.
|
||||
*/
|
||||
flush(draft: PreviewDraft): void {
|
||||
this.setPending(true);
|
||||
if (this.timer) {
|
||||
clearTimeout(this.timer);
|
||||
this.timer = null;
|
||||
@@ -75,6 +80,7 @@ export class PreviewRequester {
|
||||
}
|
||||
this.inFlight?.abort();
|
||||
this.inFlight = null;
|
||||
this.setPending(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +112,16 @@ export class PreviewRequester {
|
||||
} catch (error) {
|
||||
if (!isAbort(error)) this.options.onError?.(error);
|
||||
} finally {
|
||||
if (this.inFlight === controller) this.inFlight = null;
|
||||
if (this.inFlight === controller) {
|
||||
this.inFlight = null;
|
||||
if (!this.timer) this.setPending(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private setPending(pending: boolean): void {
|
||||
if (this.pending === pending) return;
|
||||
this.pending = pending;
|
||||
this.options.onPendingChange?.(pending);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user