mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 12:02:50 +08:00
feat(kaak): keep server rail colors stable
This commit is contained in:
1 parent
8aefed83d1
commit
a1f92cedb2
11 files changed
+30
-14
No files matched your search
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user