From 2d3a9b334deaa63cd2dc5fb0092446eddd393d2f Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 18 Dec 2014 12:28:14 -0500 Subject: [PATCH] FIX: LazyYT was not being applied when a post was edited --- app/assets/javascripts/discourse/lib/plugin-api.js.es6 | 8 ++++++-- app/assets/javascripts/discourse/views/post_view.js | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/plugin-api.js.es6 b/app/assets/javascripts/discourse/lib/plugin-api.js.es6 index ab1c70983..32a9965a6 100644 --- a/app/assets/javascripts/discourse/lib/plugin-api.js.es6 +++ b/app/assets/javascripts/discourse/lib/plugin-api.js.es6 @@ -1,11 +1,15 @@ +var _decorateId = 0; + function decorate(klass, evt, cb) { var mixin = {}; - mixin["_decorate_" + new Date().getTime().toString()] = function($elem) { cb($elem); }.on(evt); + mixin["_decorate_" + (_decorateId++)] = function($elem) { cb($elem); }.on(evt); klass.reopen(mixin); } export function decorateCooked(container, cb) { - decorate(Discourse.PostView, 'postViewInserted', cb); + var postView = container.lookupFactory('view:post'); + decorate(postView, 'postViewInserted', cb); + decorate(postView, 'postViewUpdated', cb); decorate(container.lookupFactory('view:composer'), 'previewRefreshed', cb); decorate(container.lookupFactory('view:embedded-post'), 'previewRefreshed', cb); decorate(container.lookupFactory('view:user-stream'), 'didInsertElement', cb); diff --git a/app/assets/javascripts/discourse/views/post_view.js b/app/assets/javascripts/discourse/views/post_view.js index 32dbf746e..f95f12e25 100644 --- a/app/assets/javascripts/discourse/views/post_view.js +++ b/app/assets/javascripts/discourse/views/post_view.js @@ -45,9 +45,14 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, { // If the cooked content changed, add the quote controls cookedChanged: function() { - Em.run.scheduleOnce('afterRender', this, '_insertQuoteControls'); + Em.run.scheduleOnce('afterRender', this, '_cookedWasChanged'); }.observes('post.cooked'), + _cookedWasChanged: function() { + this.trigger('postViewUpdated', this.$()); + this._insertQuoteControls(); + }, + mouseUp: function(e) { if (this.get('controller.multiSelect') && (e.metaKey || e.ctrlKey)) { this.get('controller').toggledSelectedPost(this.get('post'));