From 22525ff74c821a9c7da2ee9ba73ce2e974f1d63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Fri, 31 Oct 2014 12:01:47 +0100 Subject: [PATCH] FIX: changing title of a poll should close/open the poll --- .../poll/assets/javascripts/initializers/poll.js.es6 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/poll/assets/javascripts/initializers/poll.js.es6 b/plugins/poll/assets/javascripts/initializers/poll.js.es6 index 2e7e2eaa6ba..c55cac7eca9 100644 --- a/plugins/poll/assets/javascripts/initializers/poll.js.es6 +++ b/plugins/poll/assets/javascripts/initializers/poll.js.es6 @@ -9,9 +9,12 @@ var Poll = Discourse.Model.extend({ this.updateFromJson(this.get('post.poll_details')); }.observes('post.poll_details'), - fetchNewPostDetails: function() { - this.get('post.topic.postStream').triggerChangedPost(this.get('post.id'), this.get('post.topic.updated_at')); - }.observes('post.topic.title'), + fetchNewPostDetails: Discourse.debounce(function() { + var self = this; + Discourse.debounce(function() { + self.get('post.topic.postStream').triggerChangedPost(self.get('post.id'), self.get('post.topic.updated_at')); + }, 500); + }).observes('post.topic.title'), updateFromJson: function(json) { var selectedOption = json["selected"]; @@ -24,8 +27,8 @@ var Poll = Discourse.Model.extend({ checked: (option === selectedOption) })); }); - this.set('options', options); + this.set('options', options); this.set('closed', json.closed); },