25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(redis): stop duplicating pubsub messages
onenewcoded70c883e8164
diff --git a/apps/desktop/src/components/redis/RedisPubSubPanel.vue b/apps/desktop/src/components/redis/RedisPubSubPanel.vueindex 986db15ed2..e2239ca355 100644--- a/apps/desktop/src/components/redis/RedisPubSubPanel.vue+++ b/apps/desktop/src/components/redis/RedisPubSubPanel.vue@@ -65,21 +65,24 @@ async function connect() {if (ws && ws.readyState === WebSocket.OPEN) return;connecting.value = true;try {- ws = await api.redisPubSubConnect(props.connectionId);+ const socket = await api.redisPubSubConnect(props.connectionId);+ ws = socket;- ws.onopen = () => {+ socket.onopen = () => {+ if (ws !== socket) return;connected.value = true;connecting.value = false;// Re-subscribe existing channelsif (channels.value.length > 0) {- ws!.send(JSON.stringify({ type: "subscribe", channels: channels.value }));+ socket.send(JSON.stringify({ type: "subscribe", channels: channels.value }));}if (patterns.value.length > 0) {- ws!.send(JSON.stringify({ type: "psubscribe", patterns: patterns.value }));+ socket.send(JSON.stringify({ type: "psubscribe", patterns: patterns.value }));}};- ws.onmessage = (event) => {+ socket.onmessage = (event) => {+ if (ws !== socket) return;try {const data = JSON.parse(event.data as string);if (data.error) {@@ -92,13 +95,15 @@ async function connect() {}};- ws.onclose = () => {+ socket.onclose = () => {+ if (ws !== socket) return;connected.value = false;connecting.value = false;ws = null;};- ws.onerror = () => {+ socket.onerror = () => {+ if (ws !== socket) return;connected.value = false;connecting.value = false;ws = null;@@ -110,11 +115,11 @@ async function connect() {}function disconnect() {- if (ws) {- ws.close();- ws = null;- connected.value = false;- }+ const socket = ws;+ ws = null;+ connected.value = false;+ connecting.value = false;+ if (socket) socket.close();}function subscribe() {@@ -159,11 +164,6 @@ async function publish() {if (!ch || !msg) return;try {await api.redisPubSubPublish(props.connectionId, props.db, ch, msg);- // Echo locally only if subscribed — Redis PubSub doesn't deliver to publisher- const isSubscribed = channels.value.includes(ch) || patterns.value.some((p) => new RegExp("^" + p.replace(/\*/g, ".*") + "$").test(ch));- if (isSubscribed) {- addMessage(ch, null, msg);- }publishMessage.value = "";} catch (e) {toast(t("redis.pubsubPublishFailed", { error: e instanceof Error ? e.message : String(e) }), 3000);