feat: update components and hooks to use get_untracked for improved performance
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* E2E API tests — runs against a running backend instance.
|
||||
* Usage: vitest run (or: API_BASE=http://localhost:3001 vitest run)
|
||||
*/
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const BASE = process.env.API_BASE ?? "https://imphnen.asepharyana.my.id/api";
|
||||
|
||||
|
||||
@@ -18,11 +18,8 @@ import { createRecordingsRouter } from "../modules/recordings/recordings.routes.
|
||||
import { createUiStateRouter } from "../modules/ui-state/ui-state.routes.js";
|
||||
import { createGuildsRouter } from "../modules/voice/guilds.routes.js";
|
||||
import { createVoiceRouter } from "../modules/voice/voice.routes.js";
|
||||
import {
|
||||
adminAuth,
|
||||
errorHandler,
|
||||
} from "../shared/middlewares/index.js";
|
||||
import { config } from "../shared/config/index.js";
|
||||
import { adminAuth, errorHandler } from "../shared/middlewares/index.js";
|
||||
|
||||
const ADMIN_PASSWORD = config.ADMIN_PASSWORD || "admin";
|
||||
|
||||
|
||||
@@ -67,7 +67,9 @@ export class RecordingsService {
|
||||
|
||||
const items = rows.slice(0, limit) as unknown as RecordingRow[];
|
||||
const hasMore = rows.length > limit;
|
||||
const nextCursor = hasMore ? String(items[items.length - 1]!.created_at) : null;
|
||||
const nextCursor = hasMore
|
||||
? String(items[items.length - 1]!.created_at)
|
||||
: null;
|
||||
|
||||
return { items, nextCursor, hasMore };
|
||||
}
|
||||
|
||||
@@ -2,7 +2,11 @@ import { createChildLogger } from "@bete/shared/logger";
|
||||
import type { Request, Response } from "express";
|
||||
import { asyncHandler } from "../../shared/middlewares/index.js";
|
||||
import { publishCommandNoReply } from "../../shared/redis/index.js";
|
||||
import { connectVoice, disconnectVoice, getVoiceStatus } from "./voice.service.js";
|
||||
import {
|
||||
connectVoice,
|
||||
disconnectVoice,
|
||||
getVoiceStatus,
|
||||
} from "./voice.service.js";
|
||||
|
||||
const logger = createChildLogger("voice.controller");
|
||||
|
||||
|
||||
@@ -166,4 +166,3 @@ export async function disconnectVoice(): Promise<VoiceStatus> {
|
||||
"disconnectVoice",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,29 +115,27 @@ export function createWebSocketServer(server: Server): WebSocketServer {
|
||||
data[0] === 0x50 && // 'P'
|
||||
data[1] === 0x43 && // 'C'
|
||||
data[2] === 0x4d && // 'M'
|
||||
data[3] === 0x00 // '\0'
|
||||
data[3] === 0x00 // '\0'
|
||||
) {
|
||||
const pcmBuffer = data.subarray(4);
|
||||
const base64 = pcmBuffer.toString("base64");
|
||||
import("../shared/redis/index.js").then(
|
||||
({ getCommandPublisher }) => {
|
||||
const publisher = getCommandPublisher();
|
||||
publisher
|
||||
.publish(
|
||||
BACKEND_VOICE_TRANSMIT,
|
||||
JSON.stringify({
|
||||
type: "pcm",
|
||||
buffer: base64,
|
||||
}),
|
||||
)
|
||||
.catch((err: Error) => {
|
||||
logger.error(
|
||||
{ err },
|
||||
"Failed to publish voice transmit to Redis",
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
import("../shared/redis/index.js").then(({ getCommandPublisher }) => {
|
||||
const publisher = getCommandPublisher();
|
||||
publisher
|
||||
.publish(
|
||||
BACKEND_VOICE_TRANSMIT,
|
||||
JSON.stringify({
|
||||
type: "pcm",
|
||||
buffer: base64,
|
||||
}),
|
||||
)
|
||||
.catch((err: Error) => {
|
||||
logger.error(
|
||||
{ err },
|
||||
"Failed to publish voice transmit to Redis",
|
||||
);
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -243,10 +241,7 @@ export function createWebSocketServer(server: Server): WebSocketServer {
|
||||
try {
|
||||
client.send(data);
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
{ err },
|
||||
"Failed to send binary to frontend client",
|
||||
);
|
||||
logger.error({ err }, "Failed to send binary to frontend client");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user