You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I first of all want to say that I really enjoy using Payload and currently working on a project to replace a Wordpress (siuu😎) website to Payload which goes quite smoothly. Only there is one issue which I can't seem to solve easily and is also a request from the customer as they want to know what post is online and which is just in draft mode in the collection screen.
Because when you publish a post, the status changes to published, and when you make a change in the document it goes to draft as that is the current latest version, which makes sense. But it is quite confusing if you see an already published post having the status draft.
I was thinking of adding a virtual property that will determine of a post is online, but then I need to call the database to check if this post has a published version, and doing that each time feels a bit to much. (or not?)
I also have a similar issue unpublishing, because every published post is scheduled, which triggers some jobs that will run later to do some social media stuff. But when the user unpublishes, I need to determine it is not a draft change but a real change from publish to draft to stop all the processes. But determining that is not easy, and every change in the document will result in triggering this hook that does the check.
For example this hook will also trigger if I am changing a published document, which makes automatically a draft version, so hard to tell if we are doing an unpublish:
exportconsthandleUnPublishHook: CollectionAfterChangeHook<Article>=async({
req,
doc,
previousDoc,
operation,})=>{if(operation==='update'&&previousDoc){if(previousDoc._status==='published'&&doc._status==='draft'){// Are we unpublishing?}}returndoc}
TL;DR: How to determine easily if a document is published, and also when it is unpublishing.. 😅
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I first of all want to say that I really enjoy using Payload and currently working on a project to replace a Wordpress (siuu😎) website to Payload which goes quite smoothly. Only there is one issue which I can't seem to solve easily and is also a request from the customer as they want to know what post is online and which is just in draft mode in the collection screen.
Because when you publish a post, the status changes to published, and when you make a change in the document it goes to draft as that is the current latest version, which makes sense. But it is quite confusing if you see an already published post having the status draft.
I was thinking of adding a virtual property that will determine of a post is online, but then I need to call the database to check if this post has a published version, and doing that each time feels a bit to much. (or not?)
I also have a similar issue unpublishing, because every published post is scheduled, which triggers some jobs that will run later to do some social media stuff. But when the user unpublishes, I need to determine it is not a draft change but a real change from publish to draft to stop all the processes. But determining that is not easy, and every change in the document will result in triggering this hook that does the check.
For example this hook will also trigger if I am changing a published document, which makes automatically a draft version, so hard to tell if we are doing an unpublish:
TL;DR: How to determine easily if a document is published, and also when it is unpublishing.. 😅
Beta Was this translation helpful? Give feedback.
All reactions