From d5b003a15e782b7cf94a56b3daaab9cd08ce1424 Mon Sep 17 00:00:00 2001 From: Benedikt Radtke Date: Mon, 27 Jun 2016 14:47:33 +0200 Subject: [PATCH] Fixed media pausing behaviour when clicking the conversation list This commit changes the inbox to stop video and audio elements when selecting a new conversation, and to not stop such elements when the same conversation was selected (fixes #391). // FREEBIE --- js/views/inbox_view.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/js/views/inbox_view.js b/js/views/inbox_view.js index 5dc6f9cc3..ea6b67b5b 100644 --- a/js/views/inbox_view.js +++ b/js/views/inbox_view.js @@ -38,16 +38,25 @@ Whisper.ConversationStack = Whisper.View.extend({ className: 'conversation-stack', open: function(conversation) { - var $el = this.$('#conversation-' + conversation.cid); - if ($el === null || $el.length === 0) { - var view = new Whisper.ConversationView({ - model: conversation, - appWindow: this.model.appWindow + var id = 'conversation-' + conversation.cid; + if(id !== this.el.firstChild.id) { + this.$("video").each(function() { + this.pause(); }); - $el = view.$el; + this.$("audio").each(function() { + this.pause(); + }); + var $el = this.$('#'+id); + if ($el === null || $el.length === 0) { + var view = new Whisper.ConversationView({ + model: conversation, + appWindow: this.model.appWindow + }); + $el = view.$el; + } + $el.prependTo(this.el); + conversation.trigger('opened'); } - $el.prependTo(this.el); - conversation.trigger('opened'); } });