Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions src/actions/portal/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { createServer as createLiveReloadServer } from "livereload";
import connectLiveReload from "connect-livereload";
import express, { Express } from "express";
import chokidar from "chokidar";
import crypto from "crypto";
import { Mutex } from "async-mutex";
import { PortalServePrompts } from "../../prompts/portal/serve.js";
import { DirectoryPath } from "../../types/file/directoryPath.js";
import { ActionResult } from "../action-result.js";
Expand Down Expand Up @@ -86,10 +84,6 @@ export class PortalServeAction {
});

const deletedDirectories = new Set<string>();
// TODO: Verify if we need mutex and eventQueue after refactoring.
const eventQueue = new Map();
const mutex = new Mutex();

const debounceService: DebounceService = new DebounceService();

watcher
Expand All @@ -105,22 +99,10 @@ export class PortalServeAction {
}
}
}
const eventId: string = `${Date.now()}-${crypto.randomUUID()}`;
await mutex.runExclusive(async () => {
eventQueue.clear();
eventQueue.set(eventId, path);
});

await debounceService.batchSingleRequest(async () => {
this.prompts.changesDetected();

// TODO: Verify if this is needed.
if (!eventQueue.has(eventId)) {
return;
}

await generatePortalAction.execute(buildDirectory, portalDirectory, true, false, false);

liveReloadServer.refresh(portalDirectory.toString());
this.clearStandardInput();
});
Expand Down
3 changes: 3 additions & 0 deletions src/infrastructure/debounce-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export class DebounceService {
}
} finally {
this.isProcessing = false;
if (this.latestHandler) {
this.scheduleExecution();
}
}
}, this.debounceMs);
}
Expand Down