From 488f25635decd3c6fdf08a6e53b1911065a87fb6 Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 12 Feb 2015 20:36:44 -0800 Subject: [PATCH] Wire up end session and leave group Closes #136 Closes #137 --- js/models/conversations.js | 13 +++++++++++++ js/views/conversation_view.js | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/js/models/conversations.js b/js/models/conversations.js index d20ad5f8..3507bfed 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -106,6 +106,19 @@ }); }, + endSession: function() { + if (this.get('type') === 'private') { + textsecure.messaging.closeSession(this.id); + } + + }, + + leaveGroup: function() { + if (this.get('type') === 'group') { + textsecure.messaging.leaveGroup(this.id); + } + }, + receiveMessage: function(decrypted) { var conversation = this; var timestamp = decrypted.pushMessage.timestamp.toNumber(); diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 2e91d731..0c190244 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -52,12 +52,24 @@ 'submit .send': 'sendMessage', 'close': 'remove', 'click .destroy': 'destroyMessages', + 'click .end-session': 'endSession', + 'click .leave-group': 'leaveGroup', 'click .new-group-update': 'newGroupUpdate', 'click .settings-btn': 'toggleSettings', 'click .go-back': 'toggleSettings', 'click .hamburger': 'toggleMenu' }, + endSession: function() { + this.model.endSession(); + this.$el.find('.menu-list').hide(); + }, + + leaveGroup: function() { + this.model.leaveGroup(); + this.$el.find('.menu-list').hide(); + }, + toggleMenu: function() { this.$el.find('.menu-list').toggle(); }, @@ -80,6 +92,7 @@ this.remove(); this.model.trigger('destroy'); } + this.$el.find('.menu-list').hide(); }, sendMessage: function(e) {