Thanks for the reply. I currently have this in my initializer:
var hide = true; // this gets toggled true/false whenever the button is pressed.
function initializeHideToggle(api) {
api.includePostAttributes('hide_devs');
api.modifyClass('model:composer', {
hide_devs: hide,
@on('init')
@observes('post')
@observes('model.composeState')
setHide() {
this.set('hide_devs', hide);
},
});
}
export default {
name: "toggle-hidedevs",
initialize(container) {
Composer.serializeOnCreate('hide_devs', 'hide_devs');
const siteSettings = container.lookup('site-settings:main');
if (siteSettings.hide_devs_enabled) {
withPluginApi('0.1', api => initializeHideToggle(api), {
noApi: () => priorToApi(container)
});
}
}
};
Like mentioned in the previous post, I get the hide_devs variable in the plugin.rb file correctly, however it’s the value from when the editor was last openend, instead of when the post was created. Not sure what to listen for to make it update according the value on “post”. I’ve tried looking through the discourse source files to find an observes example that would trigger on “post” but I’ve not yet found one that seems to do something like that.
I’ll have a look, thanks for the suggestion!