MDL-54687 core_message: remove contact from DOM if no messages remain
authorMark Nelson <markn@moodle.com>
Thu, 11 Aug 2016 11:24:07 +0000 (19:24 +0800)
committerMark Nelson <markn@moodle.com>
Fri, 7 Oct 2016 08:26:40 +0000 (16:26 +0800)
message/amd/src/message_area_messages.js

index 423fee1..1dea422 100644 (file)
@@ -297,6 +297,12 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
                         }
                     }.bind(this));
 
+                    // If there are no messages at all, then remove conversation panel.
+                    if (this.messageArea.find(this.messageArea.SELECTORS.MESSAGE).length === 0) {
+                        this.messageArea.find(this.messageArea.SELECTORS.CONVERSATIONS + " " +
+                            this.messageArea.SELECTORS.CONTACT + "[data-userid='" + this._getUserId() + "']").remove();
+                    }
+
                     // Trigger event letting other modules know messages were deleted.
                     this.messageArea.trigger(this.messageArea.EVENTS.MESSAGESDELETED, this._getUserId());
                 }.bind(this), notification.exception);