mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -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) {
|
function PostsSetPostedAt (modifier, post) {
|
||||||
modifier.$set.postedAt = new Date();
|
modifier.$set.postedAt = new Date();
|
||||||
|
if (modifier.$unset) {
|
||||||
|
delete modifier.$unset.postedAt;
|
||||||
|
}
|
||||||
return modifier;
|
return modifier;
|
||||||
}
|
}
|
||||||
addCallback("posts.approve.sync", PostsSetPostedAt);
|
addCallback("posts.approve.sync", PostsSetPostedAt);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import marked from 'marked';
|
import marked from 'marked';
|
||||||
import Posts from '../collection.js'
|
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 //
|
// posts.edit.sync //
|
||||||
|
@ -38,15 +38,17 @@ addCallback("posts.edit.sync", PostsEditForceStickyToFalse);
|
||||||
*/
|
*/
|
||||||
function PostsEditSetIsFuture (modifier, post) {
|
function PostsEditSetIsFuture (modifier, post) {
|
||||||
// if a post's postedAt date is in the future, set isFuture to true
|
// 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;
|
return modifier;
|
||||||
}
|
}
|
||||||
addCallback("posts.edit.sync", PostsEditSetIsFuture);
|
addCallback("posts.edit.sync", PostsEditSetIsFuture);
|
||||||
|
|
||||||
|
|
||||||
function PostsEditRunPostApprovedSyncCallbacks (modifier, post) {
|
function PostsEditRunPostApprovedSyncCallbacks (modifier, post) {
|
||||||
if (Posts.isApproved(modifier) && !Posts.isApproved(post)) {
|
if (modifier.$set && Posts.isApproved(modifier.$set) && !Posts.isApproved(post)) {
|
||||||
modifier = runCallbacksAsync("posts.approve.sync", modifier, post);
|
modifier = runCallbacks("posts.approve.sync", modifier, post);
|
||||||
}
|
}
|
||||||
return modifier;
|
return modifier;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue