mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-09-16 10:42:41 +00:00
## Problem Adding a channel key in the Channels UI for a channel the server already knows about (e.g. `#public` from rainbow / config) leaves the localStorage entry **unremovable**: - `mergeUserChannels` sees the name already exists in the channel list and skips the user entry. - The existing channel row is never marked `userAdded:true`. - The ✕ button (`[data-remove-channel]`) is only rendered for `userAdded` rows. - Result: stuck localStorage key, no UI to delete it. There was also a latent bug in the remove handler — for non-`user:` rows, it used the raw hash (e.g. `enc_11`) as the `ChannelDecrypt.removeKey()` argument, but the storage key is the channel **name**. ## Fix 1. **`mergeUserChannels`**: when a stored key matches an existing channel by name/hash, mark the existing channel `userAdded=true` so the ✕ renders on it. (No magical/auto deletion of stored keys — the user explicitly chooses to remove.) 2. **Remove handler**: - Look up the channel object to get the correct display name for the localStorage key. - Keep server-known channels in the list when their ✕ is clicked (only the user's localStorage entry + cache are cleared, `userAdded` is unset). The channel still exists upstream. - Pure `user:`-prefixed channels are removed from the list as before. ## Repro 1. Open Channels. 2. Add a key for `#public` (or any rainbow-known channel). 3. Reload. Before this PR: row has no ✕, key is stuck. After this PR: ✕ appears, click clears the local key and cache. ## Files - `public/channels.js` only. ## Notes - No backend changes. - No new APIs. - Behaviour for purely user-added channels (e.g. `user:#somechannel` not known to the server) is unchanged. --------- Co-authored-by: you <you@example.com>