From 8dcdda95ac818979b5f1fc5c9ec86e22cea85536 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Tue, 14 Jan 2020 11:39:44 -0500 Subject: [PATCH] Added moment utc transformation to post compose api call for scheduled posts --- app/javascript/gabsocial/actions/compose.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/javascript/gabsocial/actions/compose.js b/app/javascript/gabsocial/actions/compose.js index fe3cfa5a..e738c482 100644 --- a/app/javascript/gabsocial/actions/compose.js +++ b/app/javascript/gabsocial/actions/compose.js @@ -1,6 +1,7 @@ import api from '../api'; import { CancelToken, isCancel } from 'axios'; import { throttle } from 'lodash'; +import moment from 'moment'; import { search as emojiSearch } from '../features/emoji/emoji_mart_search_light'; import { tagHistory } from '../settings'; import { useEmoji } from './emojis'; @@ -198,8 +199,12 @@ export function submitCompose(routerHistory, group) { : `/api/v1/statuses/${id}`; const method = id === null ? 'post' : 'put'; + let scheduled_at = getState().getIn(['compose', 'scheduled_at'], null); + if (scheduled_at !== null) scheduled_at = moment.utc(scheduled_at).toDate(); + api(getState)[method](endpoint, { status, + scheduled_at, in_reply_to_id: getState().getIn(['compose', 'in_reply_to'], null), quote_of_id: getState().getIn(['compose', 'quote_of_id'], null), media_ids: media.map(item => item.get('id')), @@ -208,7 +213,6 @@ export function submitCompose(routerHistory, group) { visibility: getState().getIn(['compose', 'privacy']), poll: getState().getIn(['compose', 'poll'], null), group_id: group ? group.get('id') : null, - scheduled_at: getState().getIn(['compose', 'scheduled_at'], null), }, { headers: { 'Idempotency-Key': getState().getIn(['compose', 'idempotencyKey']),