how change post quick reply component become editor?
ed5bfe2d-fb9a-41f3-8b77-b33ae0c7d0c8-image.png
2c12236d-3bbf-4d3c-8f26-4ffc3490277d-image.png
Is there a hook on the customer side when a post enters a queue of posts and waits for approval?
Not a filter hook but an action hook - to perform a specific action when the post enters the queue.
You can use action:composer.topics.post
& action:composer.posts.reply
These get triggered after the user submits with the composer. To check if the post was queued you can look at the data passed to these hooks.
hooks.on('action:composer.topics.post', function (hookData) {
console.log('isQueued', hookData.data.queued);
});
@baris said in Hook on the client side when a post enters a queue of posts:
You can use action:composer.topics.post & action:composer.posts.reply These get triggered after the user submits with the composer.
Thanks it works!
Why are they not listed (https://github.com/NodeBB/NodeBB/wiki/Hooks) ?!
Where can I get a better and complete list?
@baris said in Hook on the client side when a post enters a queue of posts:
hooks.on('action:composer.topics.post', function (hookData) {
console.log('isQueued', hookData.data.queued);
});
It gives me back an error:
VM178: 1 Uncaught ReferenceError: hooks is not defined
at <anonymous>: 1: 1
I guess that was an example; But I did not understand how to use it (I quite understand basic JS but do not know so much about the use of NODEBB)
Can you expand on that?
Thanks
The autogenerated hooks page doesn't catch dynamic hooks like action:composer.' + type
. These hooks are located at https://github.com/NodeBB/nodebb-plugin-composer-default/blob/master/static/lib/composer.js#L800
You need to require the hooks
module before using it, for example.
require(['hooks'], function (hooks) {
hooks.on('action:composer.topics.post', function (hookData) {
console.log('isQueued', hookData.data.queued);
});
});
@baris It still does not work...
It does not print anything on the console
It stays that way even after the post is sent.
From what I understand, this type of hook is in the following structure:
"action: composer." + Action.
The question is is there a list of acceptable actions? For example onShow, onHide, discard ...
The value actions
for this hook are topics.post
, posts.reply
and posts.edit
.
Are you putting the code in browser console and trying to post a new topic?
Try using the below, without the hooks module
$(window).on('action:composer.topics.post', function (ev, hookData) {
console.log('isQueued', hookData.data.queued);
});
@baris said in Hook on the client side when a post enters a queue of posts:
Are you putting the code in browser console and trying to post a new topic?
Yes exactly.
@baris said in Hook on the client side when a post enters a queue of posts:
$(window).on('action:composer.topics.post', function (ev, hookData) {
console.log('isQueued', hookData.data.queued);
});
I tried it too - same thing, nothing printed.
@baris said in Hook on the client side when a post enters a queue of posts:
The value actions for this hook are topics.post, posts.reply and posts.edit.
Thanks. Is there a place where this is neatly detailed?
Without having to look much at the source code ...
Not right now the only source is the wiki page but like I said that doesn't catch if the hook name is generated in javascript.
The code I posted works for me btw, I added the code in the browser console and made a new post and saw isQueued being logged.
@baris Here's a screen shot - hope it's clear enough.
Hard to tell what's going on in that gif, seems like there are some javascript errors and the page refreshes.
@baris I tried here in the forum the code you gave - and it did not work ...
@josef Here is a screenshot showing it works for replies.
@baris I did exactly the same thing, and nothing was printed ...
I made 2 small screenshots (4.4 MB total) that show this.
You are using the wrong hook name
action:composer.topics.post
=> for new topic
action:composer.posts.reply
=> for new reply