Skip to content

Commit

Permalink
[REVERT-4398] Add check if schedule post is active before applying ac…
Browse files Browse the repository at this point in the history
…tivity data
  • Loading branch information
amincdev committed May 10, 2024
1 parent 6e43584 commit 607f317
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
40 changes: 21 additions & 19 deletions src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global bp, BP_Nouveau, _, Backbone, tinymce, bp_media_dropzone */
/* global bp, BP_Nouveau, _, Backbone, tinymce, bp_media_dropzone, bbSchedulePostsVars */
/* @version 3.1.0 */
/*jshint esversion: 6 */
window.wp = window.wp || {};
Expand Down Expand Up @@ -386,28 +386,30 @@ window.bp = window.bp || {};
self.postForm.model.set( 'link_image_index', activity_data.link_image_index_save );
self.postForm.model.set( 'link_image_index_save', activity_data.link_image_index_save );

if( 'scheduled' === activity_data.activity_action_type || 'scheduled' === activity_data.status ) {
if( bbSchedulePostsVars.activity_schedule_enabled ) {
if( 'scheduled' === activity_data.activity_action_type || 'scheduled' === activity_data.status ) {

// Set Schedule post data.
self.postForm.model.set( 'activity_schedule_date_raw', activity_data.activity_schedule_date_raw );
self.postForm.model.set( 'activity_schedule_date', activity_data.activity_schedule_date );
self.postForm.model.set( 'activity_schedule_time', activity_data.activity_schedule_time );
self.postForm.model.set( 'activity_schedule_meridiem', activity_data.activity_schedule_meridiem );
// Set Schedule post data.
self.postForm.model.set( 'activity_schedule_date_raw', activity_data.activity_schedule_date_raw );
self.postForm.model.set( 'activity_schedule_date', activity_data.activity_schedule_date );
self.postForm.model.set( 'activity_schedule_time', activity_data.activity_schedule_time );
self.postForm.model.set( 'activity_schedule_meridiem', activity_data.activity_schedule_meridiem );

if( 'scheduled' === activity_data.status ) {
self.postForm.model.set( 'activity_action_type', activity_data.status );
} else {
self.postForm.model.set( 'activity_action_type', activity_data.activity_action_type );
// Check if time has passed and trigger warning.
var activity_schedule_datetime = activity_data.activity_schedule_date_raw + ' ' + activity_data.activity_schedule_time + ' ' + activity_data.activity_schedule_meridiem;
var activity_schedule_date = new Date( activity_schedule_datetime );
var current_date = new Date( bp.Nouveau.bbServerTime().currentServerTime );
if ( current_date > activity_schedule_date ) {
Backbone.trigger( 'onError', BP_Nouveau.activity.strings.scheduleWarning, 'warning' );
if( 'scheduled' === activity_data.status ) {
self.postForm.model.set( 'activity_action_type', activity_data.status );
} else {
self.postForm.model.set( 'activity_action_type', activity_data.activity_action_type );
// Check if time has passed and trigger warning.
var activity_schedule_datetime = activity_data.activity_schedule_date_raw + ' ' + activity_data.activity_schedule_time + ' ' + activity_data.activity_schedule_meridiem;
var activity_schedule_date = new Date( activity_schedule_datetime );
var current_date = new Date( bp.Nouveau.bbServerTime().currentServerTime );
if ( current_date > activity_schedule_date ) {
Backbone.trigger( 'onError', BP_Nouveau.activity.strings.scheduleWarning, 'warning' );
}
}
} else if( activity_data.status === 'published' ) {
self.postForm.$el.addClass( 'hide-schedule-button' );
}
} else if( activity_data.status === 'published' ) {
self.postForm.$el.addClass( 'hide-schedule-button' );
}

var tool_box = $( '.activity-form.focus-in #whats-new-toolbar' );
Expand Down

Large diffs are not rendered by default.

0 comments on commit 607f317

Please sign in to comment.