From cfe0c772433b55cc50e2ebd00d6d474a721fa667 Mon Sep 17 00:00:00 2001 From: lilia Date: Fri, 12 May 2017 15:16:02 -0700 Subject: [PATCH] Conversation view blocks sending to left groups Instead of attempting to send, which will throw an 'Unknown group' exception, show a toast. // FREEBIE --- _locales/en/messages.json | 4 ++++ js/views/conversation_view.js | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index a61406db5..c28ab8e98 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1,4 +1,8 @@ { + "youLeftTheGroup": { + "message": "You left the group", + "description": "Displayed when a user can't send a message because they have left the group" + }, "debugLogExplanation": { "message": "This log will be posted publicly online for contributors to view. You may examine and edit it before submitting." }, diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 69919a3b3..af051d554 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -15,6 +15,11 @@ return { toastMessage: i18n('unblockToSend') }; } }); + Whisper.LeftGroupToast = Whisper.ToastView.extend({ + render_attributes: function() { + return { toastMessage: i18n('youLeftTheGroup') }; + } + }); var MenuView = Whisper.View.extend({ toggleMenu: function() { @@ -343,12 +348,15 @@ var toast; if (extension.expired()) { toast = new Whisper.ExpiredToast(); - toast.$el.insertAfter(this.$el); - toast.render(); - return; } if (this.model.isPrivate() && storage.isBlocked(this.model.id)) { toast = new Whisper.BlockedToast(); + } + if (!this.model.isPrivate() && this.model.get('left')) { + toast = new Whisper.LeftGroupToast(); + } + + if (toast) { toast.$el.insertAfter(this.$el); toast.render(); return;