From d502f1bdee0d6aaaca88d88fc98a52d8bdabb365 Mon Sep 17 00:00:00 2001 From: lilia Date: Fri, 25 Dec 2015 21:42:47 -0800 Subject: [PATCH] i18n KeyConflictView Also refactor generic error view to make this simpler. // FREEBIE --- _locales/en/messages.json | 6 ++++++ background.html | 12 ------------ js/views/error_view.js | 28 ++++++++++++++-------------- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 449d8b5c..89e0d78f 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1,4 +1,10 @@ { + "outgoingKeyConflict": { + "message": "This contact's identity key has changed. Click to process and display." + }, + "incomingKeyConflict": { + "message": "Received message with unknown identity key. Click to process and display." + }, "unsupportedAttachment": { "message": "Unsupported attachment type. Click to save.", "description": "Displayed for incoming unsupported attachment" diff --git a/background.html b/background.html index 40d24b1a..053c638d 100644 --- a/background.html +++ b/background.html @@ -269,18 +269,6 @@
- - diff --git a/js/views/error_view.js b/js/views/error_view.js index 38f816df..f4b1725b 100644 --- a/js/views/error_view.js +++ b/js/views/error_view.js @@ -6,32 +6,32 @@ window.Whisper = window.Whisper || {}; - var ErrorView = Backbone.View.extend({ + var ErrorView = Whisper.View.extend({ className: 'error', - initialize: function() { - this.template = $('#generic-error').html(); - Mustache.parse(this.template); - }, - render: function() { - this.$el.html(Mustache.render(this.template, this.model)); - return this; + templateName: 'generic-error', + render_attributes: function() { + return this.model; } }); var KeyConflictView = ErrorView.extend({ className: 'key-conflict', + templateName: 'key-conflict', initialize: function(options) { this.message = options.message; - if (this.message.isIncoming()) { - this.template = $('#incoming-key-conflict').html(); - } else if (this.message.isOutgoing()) { - this.template = $('#outgoing-key-conflict').html(); - } - Mustache.parse(this.template); }, events: { 'click': 'select' }, + render_attributes: function() { + var errorMessage; + if (this.message.isIncoming()) { + errorMessage = 'incomingKeyConflict'; + } else { + errorMessage = 'outgoingKeyConflict'; + } + return { message: i18n(errorMessage) }; + }, select: function() { this.$el.trigger('select', {message: this.message}); },