Quick question guys:
We were using
TopicRoute.on("setupTopicController", function(event) {
topicController = event.controller
})
in a plugin’s -init.js to get access to the postStream’s “hasNoFilters” attribute.
This has been removed in commit 6381170 (https://github.com/discourse/discourse/commit/63811707e8e02fce8ec2796d72ebdf807a5396ea), and now we’re not sure how to get at that attribute anymore.
Full context:
import { withPluginApi } from 'discourse/lib/plugin-api'
import TopicRoute from 'discourse/routes/topic'
function initializePlugin(api) {
let topicController;
TopicRoute.on("setupTopicController", function(event) {
topicController = event.controller
})
api.addPostMenuButton('iso', attrs => {
return {
action: 'clickIso',
icon: topicController.get("model.postStream.hasNoFilters") ? 'user' : 'users',
title: topicController.get("model.postStream.hasNoFilters") ? 'iso.title' : 'unisoed.title',
position: 'second'
}
})
api.attachWidgetAction('post-menu', 'clickIso', function() {
if(topicController.get("model.postStream.hasNoFilters")) {
const postStream = topicController.get("model.postStream");
postStream.toggleParticipant(this.attrs.username)
.then(() => postStream.refresh())
.then(() => topicController.send("jumpToPostId", this.attrs.id));
}
else {
const postStream = topicController.get("model.postStream");
postStream.cancelFilter();
postStream.refresh()
.then(() => topicController.send("jumpToPostId", this.attrs.id));
}
})
}
export default {
name: 'iso-button',
initialize: function() {
withPluginApi('0.8.6', api => initializePlugin(api))
}
}