fix(app): channel sync keeps a new channel's empty fields out on retry, orders saves, drops stale lookups

- A rate-limited edit of a newly registered channel is retried with the
  same "never clear Discord with an empty field" rule (it was retried as
  an existing channel and cleared the topic).
- Channel edits go one at a time, and Discord's form of the name is
  written back only while the settings still hold the name that was sent,
  so a slow answer to an earlier save never overwrites a later one.
- The chat channel screen drops a Discord name/topic lookup that answers
  after the ID was changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 19:49:47 +09:00
parent 0d9c6ec984
commit d4bd4acfe9
3 changed files with 80 additions and 22 deletions

View File

@@ -140,9 +140,11 @@ function chatChannelsEditor(f, value) {
const desc = h("input", { type: "text", value: c.description ?? "", placeholder: "무엇에 쓰는 채널인지", "data-k": "description" });
// A newly registered channel starts with its Discord name and topic.
id.addEventListener("change", async () => {
if (!id.value.trim() || (name.value && desc.value)) return;
const asked = id.value.trim();
if (!asked || (name.value && desc.value)) return;
try {
const info = await api("discord_channel_info", { id: id.value.trim() });
const info = await api("discord_channel_info", { id: asked });
if (id.value.trim() !== asked) return; // the ID changed meanwhile: this answer is for another channel
if (!name.value) name.value = info.name;
if (!desc.value) desc.value = info.topic;
} catch (e) { fail(e); }