mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-02 19:42:51 +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
@@ -46,7 +46,7 @@ export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
|
||||
{
|
||||
id: BUILTIN_KAAK_SKIN_ID,
|
||||
name: "KAAK",
|
||||
version: "3.1.12",
|
||||
version: "3.1.13",
|
||||
author: "WebSpeak Project",
|
||||
license: "AGPL-3.0-only",
|
||||
description: "A KOOK-inspired voice-room workspace with collapsible voice groups and current voice-channel chat, TeamSpeak profile cards, and host-owned voice controls.",
|
||||
|
||||
@@ -464,7 +464,7 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
|
||||
const file = new File([archive], "kaak-voice.wskin", { type: "application/octet-stream" });
|
||||
const skin = await importSkinPack(file);
|
||||
assert.equal(skin.id, "community.kaak-voice");
|
||||
assert.equal(skin.version, "3.1.12");
|
||||
assert.equal(skin.version, "3.1.13");
|
||||
assert.equal(BUILTIN_SKIN_CATALOG.find((entry) => entry.id === skin.id)?.version, skin.version);
|
||||
assert.equal(skin.schemaVersion, 3);
|
||||
const home = skin.pluginData?.components.find((component) => component.page === "home");
|
||||
@@ -509,6 +509,7 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
|
||||
assert.deepEqual(findPart(voice?.root, "chat")?.when, { path: "state.chatopen", equals: true });
|
||||
assert.equal(voice?.root.attributes?.["data-chat-open"], "{{state.chatopen}}");
|
||||
assert.equal(findPart(voice?.root, "server-monogram")?.children?.[0]?.text, "{{server.monogram}}");
|
||||
assert.equal(findPart(voice?.root, "server-monogram")?.attributes?.["data-tone"], "{{server.tone}}");
|
||||
assert.deepEqual(findPart(voice?.root, "channel-voice-members")?.when, { path: "channel.members", empty: false });
|
||||
assert.equal(findPart(voice?.root, "channel-voice-member")?.repeat?.path, "channel.members");
|
||||
assert.equal(findPart(voice?.root, "channel-member-avatar")?.children?.[0]?.text, "{{voicemember.avatarInitial}}");
|
||||
@@ -528,7 +529,7 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
|
||||
assert.equal(findPart(voice?.root, "audio-controls")?.widget, "voice.audio-controls");
|
||||
assert.ok(skin.css.includes('[data-ws-plugin-part="kaak-workspace.channel-row"]'));
|
||||
assert.match(skin.css, /kaak-workspace\.voice-channel-group-toggle/);
|
||||
assert.match(skin.css, /kaak-workspace\.quick-server-item.*nth-of-type\(8n \+ 1\)/);
|
||||
assert.match(skin.css, /kaak-workspace\.server-monogram"\]\[data-tone="0"\]/);
|
||||
assert.match(skin.css, /grid-template-columns: 80px 290px/);
|
||||
assert.match(skin.css, /minmax\(340px, min\(38vw, 520px\)\)/);
|
||||
assert.match(skin.css, /grid-template-rows: 40px/);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -68,6 +68,7 @@ test("skin quick-server data redacts connection targets and resolves only host-g
|
||||
["Recent 2", "R"],
|
||||
["Friends", "F"],
|
||||
]);
|
||||
assert.ok(rows.every(({ tone }) => Number.isInteger(tone) && tone >= 0 && tone < 7));
|
||||
assert.deepEqual(rows.map(({ label, kind, favorite, current }) => [label, kind, favorite, current]), [
|
||||
["Favorite 1", "favorite", true, false],
|
||||
["Recent 2", "recent", false, false],
|
||||
@@ -75,6 +76,10 @@ test("skin quick-server data redacts connection targets and resolves only host-g
|
||||
]);
|
||||
assert.equal(JSON.stringify(rows).includes("192.0.2.10"), false);
|
||||
assert.equal(JSON.stringify(rows).includes("voice.example"), false);
|
||||
const friendsTone = rows.find(({ label }) => label === "Friends")?.tone;
|
||||
const reorderedTone = projection.project([servers[2], servers[0], servers[1]], (server) => server.id === "voice2.example:9987")
|
||||
.find(({ label }) => label === "Friends")?.tone;
|
||||
assert.equal(reorderedTone, friendsTone, "a server keeps its color tone when its saved-list position changes");
|
||||
assert.equal(projection.resolve("opaque-1")?.address, "192.0.2.10:9987");
|
||||
assert.equal(projection.resolve("192.0.2.10:9987"), undefined);
|
||||
});
|
||||
Reference in new issue
Block a user