feat(kaak): keep server rail colors stable

This commit is contained in:
Corrupted ILLUSIA committed 2026-10-10 19:51:00 +08:00
1 parent 8aefed83d1
commit a1f92cedb2
11 files changed
+30 -14

No files matched your search

+8
View File
@@ -5,6 +5,7 @@ export interface SkinPluginQuickServer {
id: string;
label: string;
monogram: string;
tone: number;
current: boolean;
kind: "favorite" | "recent";
favorite: boolean;
@@ -14,6 +15,12 @@ function randomOpaqueId(): string {
return globalThis.crypto?.randomUUID?.() ?? `quick-server-${Math.random().toString(36).slice(2)}`;
}
function safeLabelTone(label: string): number {
let hash = 0;
for (let index = 0; index < label.length; index++) hash = (Math.imul(hash, 31) + label.charCodeAt(index)) | 0;
return (hash >>> 0) % 7;
}
function containsConnectionTarget(label: string, address: string): boolean {
const candidates = new Set([address.trim()]);
try { candidates.add(splitTeamSpeakTarget(address).address.trim()); } catch { /* Persisted targets are validated on write. */ }
@@ -47,6 +54,7 @@ export function createSkinPluginQuickServerProjection(createId: () => string = r
id: opaqueId,
label: safeLabel,
monogram: Array.from(safeLabel)[0] ?? "?",
tone: safeLabelTone(safeLabel),
current: isCurrent(server),
kind: server.isFavorite ? "favorite" : "recent",
favorite: server.isFavorite,