v3: code quality pass

This commit is contained in:
khannurien
2026-03-24 18:47:05 +00:00
parent cd4076343b
commit c293f3e706
39 changed files with 1464 additions and 1555 deletions

View File

@@ -3,6 +3,7 @@ import type {
Dump,
OnlineUser,
Playlist,
ServerToClientMessage,
User,
} from "../model/interfaces.ts";
@@ -51,13 +52,13 @@ export function getOnlineUsers(): OnlineUser[] {
return Array.from(seen.values());
}
function send(socket: WebSocket, data: unknown): void {
function send(socket: WebSocket, data: ServerToClientMessage): void {
if (socket.readyState === WebSocket.OPEN) {
socket.send(JSON.stringify(data));
}
}
export function sendToUser(userId: string, data: unknown): void {
export function sendToUser(userId: string, data: ServerToClientMessage): void {
for (const client of clients) {
if (client.userId === userId) {
send(client.socket, data);
@@ -109,7 +110,7 @@ export function broadcastVoteUpdate(
function sendToPlaylistAudience(
playlist: Pick<Playlist, "isPublic" | "userId">,
data: unknown,
data: ServerToClientMessage,
): void {
for (const client of clients) {
if (playlist.isPublic || client.userId === playlist.userId) {