From f00a8f1e814c8b08fa3268f4721ba6ac96696ba4 Mon Sep 17 00:00:00 2001 From: lilia Date: Fri, 13 Feb 2015 13:12:54 -0800 Subject: [PATCH] Render end session messages correctly --- conversation.html | 1 + js/background.js | 1 + js/views/end_session_view.js | 30 ++++++++++++++++++++++++++++++ js/views/message_view.js | 4 ++++ 4 files changed, 36 insertions(+) create mode 100644 js/views/end_session_view.js diff --git a/conversation.html b/conversation.html index c1616302b..d0b9adfeb 100644 --- a/conversation.html +++ b/conversation.html @@ -105,6 +105,7 @@ + diff --git a/js/background.js b/js/background.js index 375ec35ff..0619b8783 100644 --- a/js/background.js +++ b/js/background.js @@ -176,6 +176,7 @@ decrypted_at : now, type : type, sent_at : timestamp, + flags : pushMessageContent.flags, errors : [] }); diff --git a/js/views/end_session_view.js b/js/views/end_session_view.js new file mode 100644 index 000000000..a1b1e2035 --- /dev/null +++ b/js/views/end_session_view.js @@ -0,0 +1,30 @@ +/* vim: ts=4:sw=4:expandtab + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +(function () { + 'use strict'; + + window.Whisper = window.Whisper || {}; + + Whisper.EndSessionView = Backbone.View.extend({ + tagName: "div", + className: "end-session", + render: function() { + this.$el.text("Secure session ended"); + return this; + } + }); + +})(); diff --git a/js/views/message_view.js b/js/views/message_view.js index 0ce531cae..afa674163 100644 --- a/js/views/message_view.js +++ b/js/views/message_view.js @@ -44,6 +44,8 @@ this.group_update_view = new Whisper.GroupUpdateView({ model: groupUpdate }).render(); + } else if (this.model.get('flags') === textsecure.protobuf.PushMessageContent.Flags.END_SESSION) { + this.end_session_view = new Whisper.EndSessionView(); } else { this.template = $('#message').html(); } @@ -57,6 +59,8 @@ render: function() { if (this.group_update_view) { this.$el.append(this.group_update_view.$el); + } else if (this.end_session_view) { + this.$el.append(this.end_session_view.$el); } else { this.$el.html( Mustache.render(this.template, {