Frontend support for ReplayableErrors
Eventually we'll store errors on the message model, and this change will let us render and process them.
This commit is contained in:
		
					parent
					
						
							
								4a401f07f3
							
						
					
				
			
			
				commit
				
					
						e68720f07f
					
				
			
		
					 1 changed files with 23 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -38,6 +38,20 @@
 | 
			
		|||
    }
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  var ErrorView = Backbone.View.extend({
 | 
			
		||||
      className: 'error',
 | 
			
		||||
      events: {
 | 
			
		||||
          'click' : 'replay'
 | 
			
		||||
      },
 | 
			
		||||
      replay: function() {
 | 
			
		||||
          new window.textsecure.ReplayableError(this.model).replay();
 | 
			
		||||
      },
 | 
			
		||||
      render: function() {
 | 
			
		||||
          this.$el.text(this.model.message);
 | 
			
		||||
          return this;
 | 
			
		||||
      }
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  window.Whisper = window.Whisper || {};
 | 
			
		||||
 | 
			
		||||
  Whisper.MessageView = Backbone.View.extend({
 | 
			
		||||
| 
						 | 
				
			
			@ -71,6 +85,15 @@
 | 
			
		|||
            })
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        var errors = this.model.get('errors');
 | 
			
		||||
        if (errors && errors.length) {
 | 
			
		||||
            this.$el.find('.message').append(
 | 
			
		||||
                errors.map(function(error) {
 | 
			
		||||
                    return new ErrorView({model: error}).render().el;
 | 
			
		||||
                })
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue