Open a channel only when the server accepts the join (closes #197)
check / check (push) Waiting to run
check / check (push) Waiting to run
When the server refuses a JOIN, POST /api/v1/messages answers 200 with status "error" and sends the error numeric to the queue. Both clients opened the channel anyway. JoinChannel in internal/cli/api now returns an error unless the status is "joined". cmdJoin then keeps its buffer and target and prints its usual "Join failed" line. The web client opens no tab for a refused join, whether it came from /join or from the saved channels a fresh session joins again. Model: opus-5-5
This commit was merged in pull request #198.
This commit is contained in:
+6
-2
@@ -831,10 +831,11 @@ function App() {
|
||||
// Fresh session — join any previously saved channels.
|
||||
for (const ch of saved) {
|
||||
try {
|
||||
await api("/messages", {
|
||||
const res = await api("/messages", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ command: "JOIN", to: ch }),
|
||||
});
|
||||
if (res?.status !== "joined") continue;
|
||||
setTabs((prev) => {
|
||||
if (prev.find((t) => t.type === "channel" && t.name === ch))
|
||||
return prev;
|
||||
@@ -854,10 +855,13 @@ function App() {
|
||||
name = name.trim();
|
||||
if (!name.startsWith("#")) name = "#" + name;
|
||||
try {
|
||||
await api("/messages", {
|
||||
const res = await api("/messages", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ command: "JOIN", to: name }),
|
||||
});
|
||||
// A refused join opens no tab. The error numeric that the
|
||||
// server sends to the message queue tells the user why.
|
||||
if (res?.status !== "joined") return;
|
||||
// Show the channel's tab. Preact runs this update at once on the
|
||||
// newest tab list, so the tab is found there by name: the user's
|
||||
// own JOIN event may already have added it, and other tabs may
|
||||
|
||||
Reference in New Issue
Block a user