PlugOS refactor and other tweaks (#631)
* Prep for in-process plug loading (e.g. for CF workers, Deno Deploy) * Prototype of fixed in-process loading plugs * Fix: buttons not to scroll with content * Better positioning of modal especially on mobile * Move query caching outside query * Fix annoying mouse behavior when filter box appears * Page navigator search tweaks
This commit is contained in:
@@ -37,24 +37,24 @@ export class PromiseQueue {
|
||||
resolve: (value: any) => void;
|
||||
reject: (error: any) => void;
|
||||
}[] = [];
|
||||
private running = false;
|
||||
private processing = false;
|
||||
|
||||
runInQueue(fn: () => Promise<any>): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.queue.push({ fn, resolve, reject });
|
||||
if (!this.running) {
|
||||
this.run();
|
||||
if (!this.processing) {
|
||||
this.process();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private async run(): Promise<void> {
|
||||
private async process(): Promise<void> {
|
||||
if (this.queue.length === 0) {
|
||||
this.running = false;
|
||||
this.processing = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.running = true;
|
||||
this.processing = true;
|
||||
const { fn, resolve, reject } = this.queue.shift()!;
|
||||
|
||||
try {
|
||||
@@ -64,7 +64,7 @@ export class PromiseQueue {
|
||||
reject(error);
|
||||
}
|
||||
|
||||
this.run(); // Continue processing the next promise in the queue
|
||||
this.process(); // Continue processing the next promise in the queue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user