mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FIX: polls requires a refresh to work when inserted in the stream
This commit is contained in:
parent
19a89bb501
commit
6af71bd601
2 changed files with 15 additions and 0 deletions
|
@ -21,6 +21,15 @@ export default {
|
||||||
|
|
||||||
initialize(container) {
|
initialize(container) {
|
||||||
|
|
||||||
|
const messageBus = container.lookup("message-bus:main");
|
||||||
|
|
||||||
|
// listen for back-end to tell us when a post has a poll
|
||||||
|
messageBus.subscribe("/polls", data => {
|
||||||
|
const post = container.lookup("controller:topic").get("postStream").findLoadedPost(data.post_id);
|
||||||
|
// HACK to trigger the "postViewUpdated" event
|
||||||
|
post.set("cooked", post.get("cooked") + " ");
|
||||||
|
});
|
||||||
|
|
||||||
// overwrite polls
|
// overwrite polls
|
||||||
PostView.reopen({
|
PostView.reopen({
|
||||||
_createPollViews: function($post) {
|
_createPollViews: function($post) {
|
||||||
|
|
|
@ -273,6 +273,12 @@ after_initialize do
|
||||||
whitelisted
|
whitelisted
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# tells the front-end we have a poll for that post
|
||||||
|
on(:post_created) do |post|
|
||||||
|
next if post.is_first_post? || post.custom_fields[POLLS_CUSTOM_FIELD].blank?
|
||||||
|
DiscourseBus.publish("/polls", { post_id: post.id })
|
||||||
|
end
|
||||||
|
|
||||||
add_to_serializer(:post, :polls, false) { post_custom_fields[POLLS_CUSTOM_FIELD] }
|
add_to_serializer(:post, :polls, false) { post_custom_fields[POLLS_CUSTOM_FIELD] }
|
||||||
add_to_serializer(:post, :include_polls?) { post_custom_fields.present? && post_custom_fields[POLLS_CUSTOM_FIELD].present? }
|
add_to_serializer(:post, :include_polls?) { post_custom_fields.present? && post_custom_fields[POLLS_CUSTOM_FIELD].present? }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue