mirror of
https://github.com/vale981/Vulcan
synced 2025-03-05 17:41:43 -05:00
fix posts callbacks issues
This commit is contained in:
parent
ad5c2818c0
commit
1a02f13bae
2 changed files with 9 additions and 4 deletions
|
@ -18,6 +18,9 @@ addCallback("posts.remove.sync", PostsRemoveOperations);
|
|||
*/
|
||||
function PostsSetPostedAt (modifier, post) {
|
||||
modifier.$set.postedAt = new Date();
|
||||
if (modifier.$unset) {
|
||||
delete modifier.$unset.postedAt;
|
||||
}
|
||||
return modifier;
|
||||
}
|
||||
addCallback("posts.approve.sync", PostsSetPostedAt);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import marked from 'marked';
|
||||
import Posts from '../collection.js'
|
||||
import { runCallbacksAsync, addCallback, getSetting, Utils } from 'meteor/vulcan:core';
|
||||
import { runCallbacks, runCallbacksAsync, addCallback, getSetting, Utils } from 'meteor/vulcan:core';
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// posts.edit.sync //
|
||||
|
@ -38,15 +38,17 @@ addCallback("posts.edit.sync", PostsEditForceStickyToFalse);
|
|||
*/
|
||||
function PostsEditSetIsFuture (modifier, post) {
|
||||
// if a post's postedAt date is in the future, set isFuture to true
|
||||
modifier.$set.isFuture = modifier.$set.postedAt && new Date(modifier.$set.postedAt).getTime() > new Date().getTime() + 1000;
|
||||
if (modifier.$set.postedAt && new Date(modifier.$set.postedAt).getTime() > new Date().getTime() + 1000) {
|
||||
modifier.$set.isFuture = true;
|
||||
}
|
||||
return modifier;
|
||||
}
|
||||
addCallback("posts.edit.sync", PostsEditSetIsFuture);
|
||||
|
||||
|
||||
function PostsEditRunPostApprovedSyncCallbacks (modifier, post) {
|
||||
if (Posts.isApproved(modifier) && !Posts.isApproved(post)) {
|
||||
modifier = runCallbacksAsync("posts.approve.sync", modifier, post);
|
||||
if (modifier.$set && Posts.isApproved(modifier.$set) && !Posts.isApproved(post)) {
|
||||
modifier = runCallbacks("posts.approve.sync", modifier, post);
|
||||
}
|
||||
return modifier;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue