From 2d5ed1bb83eab54b0a97d2cdbe82fc79b8b8628a Mon Sep 17 00:00:00 2001 From: Gene S Date: Wed, 17 Aug 2016 11:06:20 -0700 Subject: [PATCH] bug: removing deleted topic from view --- index.html | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 7323337e..7bded6e3 100644 --- a/index.html +++ b/index.html @@ -148,7 +148,7 @@ case "Edit": console.log("Edit topic not implemented"); break; - case "Clear chat": + case "Clear messages": topic.delMessages({before: 0, hard: false}); break; case "Mute": @@ -176,10 +176,10 @@ getMenuItems: function() { var mode = Tinode.getMeTopic().getAccessMode(this.props.topic); if (Tinode.getTopicType(this.props.topic) === "grp") { - return ["Edit", "Clear chat", mode.canPresence() ? "Mute" : "Unmute", + return ["Edit", "Clear messages", mode.canPresence() ? "Mute" : "Unmute", mode.isBanned() ? "Unblock" : "Block", "Delete"]; } else { - return ["Clear chat", mode.canPresence() ? "Mute" : "Unmute", + return ["Clear messages", mode.canPresence() ? "Mute" : "Unmute", mode.isBanned() ? "Unblock" : "Block", "Delete"]; } } @@ -685,22 +685,29 @@ if (what === "on" || what === "off" || what === "read") { this.forceUpdate(); } else if (what === "msg") { + // New message received + // Skip update if the topic is currently open, otherwise the badge will annoyingly flash. if (this.props.topicSelected !== cont.topic) { this.forceUpdate(); } } else if (what === "recv") { - // Explicitly ignoring "recv" - } else if (what === "del") { - // Currently selected topic is deleted, clear selection. + // Explicitly ignoring "recv" -- it causes no visible updates to contact list. + } else if (what === "gone" || what === "unsub") { + // Topic deleted or user unsubscribed. Remove topic from view. + + // If the currently selected topic is gone, clear the selection. if (this.props.topicSelected === cont.topic) { this.props.onTopicSelected(null); } // Redraw without the deleted topic. this.forceUpdate(); } else { - // TODO(gene): handle other types of notifications - console.log("changed (not updating for it): " + what + " in:"); + // TODO(gene): handle other types of notifications: + // * ua -- user agent changes (may display a pictogram for mobile/desktop) + // * upd -- topic 'public' updated (fetch new public and refresh) + // * del -- messages deleted (hard or soft) -- reset pill counter + console.log("changed (not updating for it): " + what + " in: " + cont.topic); } }, tnInvite: function(invite) {