Show the direct-message web tab even when other tabs change first (closes #202) #203

Merged
clawbot merged 1 commits from issue-202-web-dm-tab into next 2026-10-27 07:07:40 +01:00
+12 -5
View File
@@ -948,16 +948,23 @@ function App() {
const openDM = (targetNick) => {
if (targetNick === nickRef.current) return;
// Show the direct-message tab. Preact runs this update at once on
// the newest tab list, so the tab is found there by name: the
// server's copy of the user's message may already have added it,
// and other tabs may have opened or closed.
setTabs((prev) => {
if (prev.find((t) => t.type === "dm" && t.name === targetNick))
const idx = prev.findIndex(
(t) => t.type === "dm" && t.name === targetNick,
);
if (idx >= 0) {
setActiveTab(idx);
return prev;
}
setActiveTab(prev.length);
return [...prev, { type: "dm", name: targetNick }];
});
const idx = tabs.findIndex(
(t) => t.type === "dm" && t.name === targetNick,
);
setActiveTab(idx >= 0 ? idx : tabs.length);
};
const handleCommand = async (text) => {