From 9b0b213ba2ee56349ccb70f56a7e9593bc003b08 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 19 Feb 2016 16:03:26 -0500 Subject: [PATCH] FIX: Less safe API for icons --- app/assets/javascripts/discourse/lib/plugin-api.js.es6 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/lib/plugin-api.js.es6 b/app/assets/javascripts/discourse/lib/plugin-api.js.es6 index 444e24fb998..1a90fc088a9 100644 --- a/app/assets/javascripts/discourse/lib/plugin-api.js.es6 +++ b/app/assets/javascripts/discourse/lib/plugin-api.js.es6 @@ -6,6 +6,7 @@ import { includeAttributes } from 'discourse/lib/transform-post'; import { addToolbarCallback } from 'discourse/components/d-editor'; import { addWidgetCleanCallback } from 'discourse/components/mount-widget'; import { decorateWidget } from 'discourse/widgets/widget'; +import PageTracker from 'discourse/lib/page-tracker'; let _decorateId = 0; function decorate(klass, evt, cb) { @@ -84,7 +85,7 @@ class PluginApi { **/ addPosterIcon(cb) { decorateWidget('poster-name:after', (h, attrs) => { - const result = cb(attrs.userCustomFields, attrs); + const result = cb(attrs.userCustomFields || {}, attrs); if (result) { let iconBody; @@ -138,6 +139,10 @@ class PluginApi { addWidgetCleanCallback('post-stream', fn); } + onPageChange(fn) { + PageTracker.current().on('change', fn); + } + } let _pluginv01;