Fix channel list order and ban feedback, per-identity HWID

- Move-client dialog, permission editor and whisper menu list channels in
  channel-tree order (parent, then its subchannels) instead of a flat sort
  by the per-parent order index or no sort at all.
- A refused banclient now shows an error naming the usual causes; the UI
  logs "Ban requested" instead of claiming the ban succeeded.
- The connector sends a stable HWID derived from the identity's UID instead
  of tsclientlib's built-in one shared by every web user.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nico B.andClaude Opus 5.5 committed 2026-11-24 20:57:20 +01:00
1 parent 762554b39d
commit f67d171001
3 files changed
+110 -8

No files matched your search

+14 -7
View File
@@ -236,6 +236,7 @@ import {
} from "./ConnectionTabs";
import { BARE_URL_REGEX, renderBbcode, wrapUrls } from "./lib/bbcode";
import { parseChannelName, spacerDisplayName } from "./lib/spacer";
import { channelsInTreeOrder } from "./lib/channelOrder";
import akimoPhoto from "./assets/akimo.jpg";
import {
applyParkedGatewayEvent,
@@ -4452,7 +4453,7 @@ function MoveClientDialog({
}) {
const t = useT();
const backdrop = useBackdropDismiss(onClose);
const movable = [...channels].sort((a, b) => a.order - b.order);
const movable = channelsInTreeOrder(channels);
return (
<div className="ts-dialog-backdrop" {...backdrop}>
@@ -4470,7 +4471,7 @@ function MoveClientDialog({
<div className="ts-connection-info-loading">{t("moveClient.empty")}</div>
) : (
<ul className="ts-group-assign-list">
{movable.map((ch) => {
{movable.map(({ channel: ch, depth }) => {
const current = ch.id === currentChannelId;
const spacer = spacerDisplayName(ch.name, ch.parent === 0);
const label = spacer.isSpacer
@@ -4482,6 +4483,7 @@ function MoveClientDialog({
className={`ts-menu-item${current ? " ts-group-assign-current" : ""}`}
disabled={current || spacer.isSpacer}
onClick={() => onSelect(ch.id)}
style={depth > 0 ? { paddingLeft: `${depth * 1.25}em` } : undefined}
>
<span className="ts-menu-item-icon">
{current ? "✔️" : spacer.isSpacer ? "➖" : "📁"}
@@ -5125,8 +5127,8 @@ function PermissionsEditorDialog({
))}
{(scope === "channel" || scope === "channelclient") && (
<ul className="ts-perms-editor-list">
{channels.map((c) => (
<li key={c.id}>
{channelsInTreeOrder(channels).map(({ channel: c, depth }) => (
<li key={c.id} style={depth > 0 ? { paddingLeft: `${depth * 1.25}em` } : undefined}>
<button
className={`ts-link-button${channelId === c.id ? " ts-perms-editor-selected" : ""}`}
onClick={() => {
@@ -12727,7 +12729,8 @@ function AppInner() {
reason: banReason,
})
);
logClient("info", "Moderation", `Banned ${banTarget.name}`);
// Only a request: the server may still refuse it (an error event follows then).
logClient("info", "Moderation", `Ban requested for ${banTarget.name}`);
setBanTarget(null);
setBanReason("");
setBanSeconds("0");
@@ -13503,8 +13506,12 @@ function AppInner() {
{whisperMenuOpen && (
<div className="ts-menu ts-menu-away" ref={focusFirstItem} onKeyDown={handleMenuKeyDown}>
<div className="ts-context-menu-title">{t("whisper.channels")}</div>
{channels.map((ch) => (
<label key={ch.id} className="ts-menu-item">
{channelsInTreeOrder(channels).map(({ channel: ch, depth }) => (
<label
key={ch.id}
className="ts-menu-item"
style={depth > 0 ? { paddingLeft: `${depth * 1.25}em` } : undefined}
>
<input
type="checkbox"
checked={whisperChannelIds.has(ch.id)}
+49
View File
@@ -0,0 +1,49 @@
/** Minimal shape needed to lay channels out like the channel tree. */
export interface OrderedChannelLike {
id: number;
parent: number;
/** Position among the siblings of the same parent (not a global index). */
order: number;
}
/**
* Flattens channels in channel-tree order: each parent is followed by its
* subchannels (recursively), siblings sorted by `order`. `order` is only
* meaningful between siblings, so a flat sort by it interleaves the levels.
* Channels whose parent is missing are appended at the end as roots.
*/
export function channelsInTreeOrder<T extends OrderedChannelLike>(
channels: readonly T[],
): { channel: T; depth: number }[] {
const byParent = new Map<number, T[]>();
for (const ch of channels) {
const list = byParent.get(ch.parent);
if (list) list.push(ch);
else byParent.set(ch.parent, [ch]);
}
for (const list of byParent.values()) list.sort((a, b) => a.order - b.order || a.id - b.id);
const out: { channel: T; depth: number }[] = [];
const seen = new Set<number>();
const walk = (parent: number, depth: number) => {
for (const ch of byParent.get(parent) ?? []) {
if (seen.has(ch.id)) continue;
seen.add(ch.id);
out.push({ channel: ch, depth });
walk(ch.id, depth + 1);
}
};
walk(0, 0);
// Orphans (parent not in the list) and anything in a parent cycle.
for (const ch of channels) {
if (seen.has(ch.id)) continue;
const orphanParent = ch.parent;
for (const sibling of byParent.get(orphanParent) ?? []) {
if (seen.has(sibling.id)) continue;
seen.add(sibling.id);
out.push({ channel: sibling, depth: 0 });
walk(sibling.id, 1);
}
}
return out;
}