From fb7f0f63107e6ad43a3d304c4be07ad2a42b906d Mon Sep 17 00:00:00 2001 From: dongzhimin Date: Mon, 14 Apr 2025 21:28:38 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E5=8F=91=E6=96=87=E7=9A=84=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/material-icons/400-20px/schedule.svg | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 app/javascript/material-icons/400-20px/schedule.svg diff --git a/app/javascript/material-icons/400-20px/schedule.svg b/app/javascript/material-icons/400-20px/schedule.svg new file mode 100644 index 0000000000..d673aaf568 --- /dev/null +++ b/app/javascript/material-icons/400-20px/schedule.svg @@ -0,0 +1,6 @@ + + + + + + From 6f83b7cb91e707e5606fdbe99cc6e42738098286 Mon Sep 17 00:00:00 2001 From: dongzhimin Date: Tue, 15 Apr 2025 23:32:24 +0800 Subject: [PATCH 02/12] =?UTF-8?q?schedule=E5=9B=BE=E6=A0=87=E5=92=8C?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E5=88=9D=E6=AD=A5=E5=88=B6=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compose/components/compose_form.jsx | 9 ++++++ .../containers/schedule_button_container.js | 32 +++++++++++++++++++ .../material-icons/400-20px/schedule.svg | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 app/javascript/mastodon/features/compose/containers/schedule_button_container.js diff --git a/app/javascript/mastodon/features/compose/components/compose_form.jsx b/app/javascript/mastodon/features/compose/components/compose_form.jsx index b5e8dabb7b..c7678c8ce9 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.jsx +++ b/app/javascript/mastodon/features/compose/components/compose_form.jsx @@ -29,6 +29,8 @@ import { PollForm } from "./poll_form"; import { ReplyIndicator } from './reply_indicator'; import { UploadForm } from './upload_form'; +import ScheduleButtonContainer from '../containers/schedule_button_container'; + const allowedAroundShortCode = '><\u0085\u0020\u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\u0009\u000a\u000b\u000c\u000d'; const messages = defineMessages({ @@ -295,6 +297,7 @@ class ComposeForm extends ImmutablePureComponent { + @@ -306,6 +309,12 @@ class ComposeForm extends ImmutablePureComponent { /> +
+ + +
diff --git a/app/javascript/mastodon/features/compose/containers/schedule_button_container.js b/app/javascript/mastodon/features/compose/containers/schedule_button_container.js new file mode 100644 index 0000000000..e428270597 --- /dev/null +++ b/app/javascript/mastodon/features/compose/containers/schedule_button_container.js @@ -0,0 +1,32 @@ +import { injectIntl,defineMessages } from "react-intl"; + +import { connect } from "react-redux"; + +import ScheduleIcon from '@/material-icons/400-20px/schedule.svg?react'; +import { IconButton } from "@/mastodon/components/icon_button"; + + + + + +const mapStateToProps = () => ({ + iconComponent: ScheduleIcon, + title: defineMessages({ + title: { + id: 'compose.schedule_button.title', + defaultMessage: 'Schedule', + }, + }), + active: false, + ariaControls: 'schedule-compose-form', + size: 18, + inverted: true, +}); + +const mapDispatchToProps = dispatch => ({ + onClick () { + dispatch({ type: 'SCHEDULE_COMPOSE' }); + }, +}); + +export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(IconButton)); \ No newline at end of file diff --git a/app/javascript/material-icons/400-20px/schedule.svg b/app/javascript/material-icons/400-20px/schedule.svg index d673aaf568..350607c71e 100644 --- a/app/javascript/material-icons/400-20px/schedule.svg +++ b/app/javascript/material-icons/400-20px/schedule.svg @@ -1,6 +1,6 @@ - + From 056db885d14a903493be9b443b266085c2f8f21c Mon Sep 17 00:00:00 2001 From: dongzhimin Date: Sat, 19 Apr 2025 11:10:49 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86reducer?= =?UTF-8?q?=EF=BC=8Caction=EF=BC=8Ccontainer=E3=80=82=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E9=94=99=E8=AF=AF=EF=BC=8C=E6=97=A0=E6=B3=95=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?css=EF=BC=8Cjson=20parse=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/mastodon/actions/compose.js | 8 ++++++++ .../compose/components/compose_form.jsx | 6 ++++++ .../containers/schedule_button_container.js | 19 +++++++------------ app/javascript/mastodon/reducers/compose.js | 12 ++++++++++++ 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/app/javascript/mastodon/actions/compose.js b/app/javascript/mastodon/actions/compose.js index aa1c6de20e..28d484a73a 100644 --- a/app/javascript/mastodon/actions/compose.js +++ b/app/javascript/mastodon/actions/compose.js @@ -81,6 +81,8 @@ export const COMPOSE_CHANGE_MEDIA_ORDER = 'COMPOSE_CHANGE_MEDIA_ORDER'; export const COMPOSE_SET_STATUS = 'COMPOSE_SET_STATUS'; export const COMPOSE_FOCUS = 'COMPOSE_FOCUS'; +export const COMPOSE_CHANGE_IS_SCHEDULED = 'COMPOSE_CHANGE_IS_SCHEDULED'; + const messages = defineMessages({ uploadErrorLimit: { id: 'upload_error.limit', defaultMessage: 'File upload limit exceeded.' }, uploadErrorPoll: { id: 'upload_error.poll', defaultMessage: 'File upload not allowed with polls.' }, @@ -835,3 +837,9 @@ export const changeMediaOrder = (a, b) => ({ a, b, }); + +export function changeIsScheduled() { + return { + type: COMPOSE_IS_SCHEDULED_CHANGE, + }; +} diff --git a/app/javascript/mastodon/features/compose/components/compose_form.jsx b/app/javascript/mastodon/features/compose/components/compose_form.jsx index c7678c8ce9..ab3212bb63 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.jsx +++ b/app/javascript/mastodon/features/compose/components/compose_form.jsx @@ -71,6 +71,11 @@ class ComposeForm extends ImmutablePureComponent { singleColumn: PropTypes.bool, lang: PropTypes.string, maxChars: PropTypes.number, + + schedule_time: PropTypes.string, + schedule_timezone: PropTypes.string, + is_scheduled: PropTypes.bool.isRequired, + scheduled_at: PropTypes.string, }; static defaultProps = { @@ -312,6 +317,7 @@ class ComposeForm extends ImmutablePureComponent {
diff --git a/app/javascript/mastodon/features/compose/containers/schedule_button_container.js b/app/javascript/mastodon/features/compose/containers/schedule_button_container.js index e428270597..963bf920bc 100644 --- a/app/javascript/mastodon/features/compose/containers/schedule_button_container.js +++ b/app/javascript/mastodon/features/compose/containers/schedule_button_container.js @@ -1,31 +1,26 @@ -import { injectIntl,defineMessages } from "react-intl"; +import { injectIntl, defineMessages } from "react-intl"; import { connect } from "react-redux"; import ScheduleIcon from '@/material-icons/400-20px/schedule.svg?react'; import { IconButton } from "@/mastodon/components/icon_button"; +import { changeIsScheduled } from '../../actions/compose'; - -const mapStateToProps = () => ({ +const mapStateToProps = (state) => ({ iconComponent: ScheduleIcon, - title: defineMessages({ - title: { - id: 'compose.schedule_button.title', - defaultMessage: 'Schedule', - }, - }), - active: false, - ariaControls: 'schedule-compose-form', + title: 'schedule', + active: state.getIn(['compose', 'is_scheduled']), + size: 18, inverted: true, }); const mapDispatchToProps = dispatch => ({ onClick () { - dispatch({ type: 'SCHEDULE_COMPOSE' }); + dispatch(changeIsScheduled()); }, }); diff --git a/app/javascript/mastodon/reducers/compose.js b/app/javascript/mastodon/reducers/compose.js index bfa2ec6a06..3d8dc315fd 100644 --- a/app/javascript/mastodon/reducers/compose.js +++ b/app/javascript/mastodon/reducers/compose.js @@ -50,6 +50,7 @@ import { COMPOSE_CHANGE_MEDIA_ORDER, COMPOSE_SET_STATUS, COMPOSE_FOCUS, + COMPOSE_CHANGE_IS_SCHEDULED, } from '../actions/compose'; import { REDRAFT } from '../actions/statuses'; import { STORE_HYDRATE } from '../actions/store'; @@ -94,6 +95,11 @@ const initialState = ImmutableMap({ focusY: 0, dirty: false, }), + + schedule_time: new Date().toLocaleString('zh-CN').split('/').join('-').split(' ').join('T')+'.0', + schedule_timezone: new Date().getTimezoneOffset() > 0?'-':'+' + (0 - new Date().getTimezoneOffset() / 60) + ':' + ((0 - new Date().getTimezoneOffset() % 60) === 30 ? '30' :'00'), + is_scheduled: false, + scheduled_at: null, }); const initialPoll = ImmutableMap({ @@ -560,6 +566,12 @@ export default function compose(state = initialState, action) { return list.splice(indexA, 1).splice(indexB, 0, moveItem); }); + case COMPOSE_CHANGE_IS_SCHEDULED: + return state.withMutations(map => { + map.set('is_scheduled', !state.get('is_scheduled')); + map.set('scheduled_at', state.get('schedule_time') + state.get('schedule_timezone')); + map.set('idempotencyKey', uuid()); + }); default: return state; } From 6cd5993d8081d3631dd134331af391ace0c22050 Mon Sep 17 00:00:00 2001 From: dongzhimin Date: Sat, 19 Apr 2025 12:50:16 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../features/compose/containers/schedule_button_container.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/mastodon/features/compose/containers/schedule_button_container.js b/app/javascript/mastodon/features/compose/containers/schedule_button_container.js index 963bf920bc..ca323dd50e 100644 --- a/app/javascript/mastodon/features/compose/containers/schedule_button_container.js +++ b/app/javascript/mastodon/features/compose/containers/schedule_button_container.js @@ -5,7 +5,7 @@ import { connect } from "react-redux"; import ScheduleIcon from '@/material-icons/400-20px/schedule.svg?react'; import { IconButton } from "@/mastodon/components/icon_button"; -import { changeIsScheduled } from '../../actions/compose'; +import { changeIsScheduled } from '../../../actions/compose'; From dc2fc434f2ade15e55475b9abbb0518f0a496c06 Mon Sep 17 00:00:00 2001 From: dongzhimin Date: Sat, 19 Apr 2025 15:23:12 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E6=97=A0=E6=B3=95=E4=BC=A0=E9=80=92sched?= =?UTF-8?q?ule=5Ftime=E7=8A=B6=E6=80=81=EF=BC=8C=E4=BF=AE=E6=94=B9initialS?= =?UTF-8?q?tate=E5=90=8E=E5=86=8D=E6=AC=A1=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/mastodon/actions/compose.js | 2 +- .../mastodon/features/compose/components/compose_form.jsx | 1 + .../features/compose/containers/schedule_button_container.js | 2 +- app/javascript/mastodon/reducers/compose.js | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/javascript/mastodon/actions/compose.js b/app/javascript/mastodon/actions/compose.js index 28d484a73a..00af33a623 100644 --- a/app/javascript/mastodon/actions/compose.js +++ b/app/javascript/mastodon/actions/compose.js @@ -840,6 +840,6 @@ export const changeMediaOrder = (a, b) => ({ export function changeIsScheduled() { return { - type: COMPOSE_IS_SCHEDULED_CHANGE, + type: COMPOSE_CHANGE_IS_SCHEDULED, }; } diff --git a/app/javascript/mastodon/features/compose/components/compose_form.jsx b/app/javascript/mastodon/features/compose/components/compose_form.jsx index ab3212bb63..889a5d22ee 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.jsx +++ b/app/javascript/mastodon/features/compose/components/compose_form.jsx @@ -319,6 +319,7 @@ class ComposeForm extends ImmutablePureComponent { diff --git a/app/javascript/mastodon/features/compose/containers/schedule_button_container.js b/app/javascript/mastodon/features/compose/containers/schedule_button_container.js index ca323dd50e..379e6c65d8 100644 --- a/app/javascript/mastodon/features/compose/containers/schedule_button_container.js +++ b/app/javascript/mastodon/features/compose/containers/schedule_button_container.js @@ -1,6 +1,6 @@ import { injectIntl, defineMessages } from "react-intl"; -import { connect } from "react-redux"; +import { connect } from 'react-redux'; import ScheduleIcon from '@/material-icons/400-20px/schedule.svg?react'; import { IconButton } from "@/mastodon/components/icon_button"; diff --git a/app/javascript/mastodon/reducers/compose.js b/app/javascript/mastodon/reducers/compose.js index 3d8dc315fd..f24c4326d1 100644 --- a/app/javascript/mastodon/reducers/compose.js +++ b/app/javascript/mastodon/reducers/compose.js @@ -96,7 +96,7 @@ const initialState = ImmutableMap({ dirty: false, }), - schedule_time: new Date().toLocaleString('zh-CN').split('/').join('-').split(' ').join('T')+'.0', + schedule_time: new Date().toISOString().substring(0,16), schedule_timezone: new Date().getTimezoneOffset() > 0?'-':'+' + (0 - new Date().getTimezoneOffset() / 60) + ':' + ((0 - new Date().getTimezoneOffset() % 60) === 30 ? '30' :'00'), is_scheduled: false, scheduled_at: null, @@ -569,7 +569,7 @@ export default function compose(state = initialState, action) { case COMPOSE_CHANGE_IS_SCHEDULED: return state.withMutations(map => { map.set('is_scheduled', !state.get('is_scheduled')); - map.set('scheduled_at', state.get('schedule_time') + state.get('schedule_timezone')); + map.set('scheduled_at', state.get('schedule_time') + ':00.0' + state.get('schedule_timezone')); map.set('idempotencyKey', uuid()); }); default: From c7248c80fc384cd0b96c999b0c96a3b76db4f6f9 Mon Sep 17 00:00:00 2001 From: dongzhimin Date: Sat, 19 Apr 2025 16:04:43 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E4=BA=86reducer?= =?UTF-8?q?=E9=87=8C=E7=9A=84=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/mastodon/reducers/compose.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/mastodon/reducers/compose.js b/app/javascript/mastodon/reducers/compose.js index f24c4326d1..6281b88e00 100644 --- a/app/javascript/mastodon/reducers/compose.js +++ b/app/javascript/mastodon/reducers/compose.js @@ -96,8 +96,8 @@ const initialState = ImmutableMap({ dirty: false, }), - schedule_time: new Date().toISOString().substring(0,16), - schedule_timezone: new Date().getTimezoneOffset() > 0?'-':'+' + (0 - new Date().getTimezoneOffset() / 60) + ':' + ((0 - new Date().getTimezoneOffset() % 60) === 30 ? '30' :'00'), + schedule_time: null, + schedule_timezone: null, is_scheduled: false, scheduled_at: null, }); From a9784838fda7f814d2851d180d3ff98be7bb3da4 Mon Sep 17 00:00:00 2001 From: dongzhimin Date: Sat, 19 Apr 2025 22:20:34 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E5=AE=8C=E6=88=90?= =?UTF-8?q?=EF=BC=8C=E4=BD=86=E6=98=AF=E5=8F=AA=E8=83=BD=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=8C=97=E4=BA=AC=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/mastodon/actions/compose.js | 8 ++++ .../compose/components/compose_form.jsx | 10 +---- .../compose/components/schedule_form.jsx | 38 +++++++++++++++++++ .../containers/compose_form_container.js | 4 ++ app/javascript/mastodon/reducers/compose.js | 9 ++++- 5 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 app/javascript/mastodon/features/compose/components/schedule_form.jsx diff --git a/app/javascript/mastodon/actions/compose.js b/app/javascript/mastodon/actions/compose.js index 00af33a623..772075d9c3 100644 --- a/app/javascript/mastodon/actions/compose.js +++ b/app/javascript/mastodon/actions/compose.js @@ -82,6 +82,7 @@ export const COMPOSE_SET_STATUS = 'COMPOSE_SET_STATUS'; export const COMPOSE_FOCUS = 'COMPOSE_FOCUS'; export const COMPOSE_CHANGE_IS_SCHEDULED = 'COMPOSE_CHANGE_IS_SCHEDULED'; +export const COMPOSE_CHANGE_SCHEDULE_TIME = 'COMPOSE_CHANGE_SCHEDULE_TIME'; const messages = defineMessages({ uploadErrorLimit: { id: 'upload_error.limit', defaultMessage: 'File upload limit exceeded.' }, @@ -843,3 +844,10 @@ export function changeIsScheduled() { type: COMPOSE_CHANGE_IS_SCHEDULED, }; } + +export function changeScheduleTime(value) { + return { + type: COMPOSE_CHANGE_SCHEDULE_TIME, + value, + }; +} \ No newline at end of file diff --git a/app/javascript/mastodon/features/compose/components/compose_form.jsx b/app/javascript/mastodon/features/compose/components/compose_form.jsx index 889a5d22ee..e1e0038eb9 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.jsx +++ b/app/javascript/mastodon/features/compose/components/compose_form.jsx @@ -30,6 +30,7 @@ import { ReplyIndicator } from './reply_indicator'; import { UploadForm } from './upload_form'; import ScheduleButtonContainer from '../containers/schedule_button_container'; +import { ScheduleForm } from './schedule_form'; const allowedAroundShortCode = '><\u0085\u0020\u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\u0009\u000a\u000b\u000c\u000d'; @@ -314,14 +315,7 @@ class ComposeForm extends ImmutablePureComponent { /> -
- - -
+ diff --git a/app/javascript/mastodon/features/compose/components/schedule_form.jsx b/app/javascript/mastodon/features/compose/components/schedule_form.jsx new file mode 100644 index 0000000000..35f818321f --- /dev/null +++ b/app/javascript/mastodon/features/compose/components/schedule_form.jsx @@ -0,0 +1,38 @@ +import PropTypes from 'prop-types'; +import { useCallback } from 'react'; + +import { defineMessages, useIntl } from 'react-intl'; + +import classNames from 'classnames'; + +import { useDispatch, useSelector} from 'react-redux'; + +import { changeScheduleTime } from 'mastodon/actions/compose'; + + + +export const ScheduleForm = () => { + const is_scheduled = useSelector(state => state.getIn(['compose', 'is_scheduled'])); + const schedule_time = useSelector(state => state.getIn(['compose', 'schedule_time'])); + const dispatch = useDispatch(); + + const handleChange = useCallback(({ target: { value } }) => { + dispatch(changeScheduleTime(value)); + }, [dispatch]); + + if (!is_scheduled) { + return null; + } + + return ( +
+ + +
+ ); +} \ No newline at end of file diff --git a/app/javascript/mastodon/features/compose/containers/compose_form_container.js b/app/javascript/mastodon/features/compose/containers/compose_form_container.js index bda2edba60..dd7932cdbc 100644 --- a/app/javascript/mastodon/features/compose/containers/compose_form_container.js +++ b/app/javascript/mastodon/features/compose/containers/compose_form_container.js @@ -29,6 +29,10 @@ const mapStateToProps = state => ({ isInReply: state.getIn(['compose', 'in_reply_to']) !== null, lang: state.getIn(['compose', 'language']), maxChars: state.getIn(['server', 'server', 'configuration', 'statuses', 'max_characters'], 500), + is_scheduled: state.getIn(['compose', 'is_scheduled']), + schedule_time: state.getIn(['compose', 'schedule_time']), + schedule_timezone: state.getIn(['compose', 'schedule_timezone']), + scheduled_at: state.getIn(['compose', 'scheduled_at']), }); const mapDispatchToProps = (dispatch) => ({ diff --git a/app/javascript/mastodon/reducers/compose.js b/app/javascript/mastodon/reducers/compose.js index 6281b88e00..f4b2640719 100644 --- a/app/javascript/mastodon/reducers/compose.js +++ b/app/javascript/mastodon/reducers/compose.js @@ -51,6 +51,7 @@ import { COMPOSE_SET_STATUS, COMPOSE_FOCUS, COMPOSE_CHANGE_IS_SCHEDULED, + COMPOSE_CHANGE_SCHEDULE_TIME } from '../actions/compose'; import { REDRAFT } from '../actions/statuses'; import { STORE_HYDRATE } from '../actions/store'; @@ -97,7 +98,7 @@ const initialState = ImmutableMap({ }), schedule_time: null, - schedule_timezone: null, + schedule_timezone: '+08:00', is_scheduled: false, scheduled_at: null, }); @@ -572,6 +573,12 @@ export default function compose(state = initialState, action) { map.set('scheduled_at', state.get('schedule_time') + ':00.0' + state.get('schedule_timezone')); map.set('idempotencyKey', uuid()); }); + case COMPOSE_CHANGE_SCHEDULE_TIME: + return state.withMutations(map => { + map.set('schedule_time', action.value); + map.set('scheduled_at', state.get('schedule_time') + ':00.0' + state.get('schedule_timezone')); + map.set('idempotencyKey', uuid()); + }); default: return state; } From 3582cb29d00749387fe17bae7ea1b9cb4850ceea Mon Sep 17 00:00:00 2001 From: dongzhimin Date: Sat, 19 Apr 2025 23:43:08 +0800 Subject: [PATCH 08/12] =?UTF-8?q?action=E5=B7=B2=E7=BC=96=E5=86=99?= =?UTF-8?q?=EF=BC=8C=E5=90=8E=E7=AB=AF=E6=AD=A3=E5=B8=B8=EF=BC=8C=E4=BD=86?= =?UTF-8?q?=E6=98=AF=E5=89=8D=E7=AB=AF=E6=97=A0=E6=B3=95=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E5=BA=94=E5=AF=B9=E5=90=8E=E7=AB=AF=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/mastodon/actions/compose.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/javascript/mastodon/actions/compose.js b/app/javascript/mastodon/actions/compose.js index 772075d9c3..da3da6120e 100644 --- a/app/javascript/mastodon/actions/compose.js +++ b/app/javascript/mastodon/actions/compose.js @@ -191,6 +191,7 @@ export function submitCompose() { const status = getState().getIn(['compose', 'text'], ''); const media = getState().getIn(['compose', 'media_attachments']); const statusId = getState().getIn(['compose', 'id'], null); + const is_scheduled = getState().getIn(['compose', 'is_scheduled']); if ((!status || !status.length) && media.size === 0) { return; @@ -231,6 +232,7 @@ export function submitCompose() { visibility: getState().getIn(['compose', 'privacy']), poll: getState().getIn(['compose', 'poll'], null), language: getState().getIn(['compose', 'language']), + scheduled_at: is_scheduled ? getState().getIn(['compose', 'scheduled_at']) : null, }, headers: { 'Idempotency-Key': getState().getIn(['compose', 'idempotencyKey']), From d288c1cc40da2957698822aaf928b4aecb57f9dc Mon Sep 17 00:00:00 2001 From: dongzhimin Date: Sun, 20 Apr 2025 01:00:09 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E5=B7=B2=E4=BF=AE=E5=A4=8D=E3=80=82=E7=9B=AE=E5=89=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8BUG=EF=BC=9A=E5=BF=85=E9=A1=BB=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=B6=E9=97=B4=EF=BC=8C=E6=88=96=E6=89=93?= =?UTF-8?q?=E5=BC=80=E8=AE=A1=E5=88=92=E6=8C=89=E9=92=AE=EF=BC=8C=E5=90=A6?= =?UTF-8?q?=E5=88=99=E4=BC=9A=E5=8F=98=E4=B8=BA=E7=AB=8B=E5=8D=B3=E5=8F=91?= =?UTF-8?q?=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/mastodon/actions/compose.js | 13 +++++++++++++ app/javascript/mastodon/reducers/compose.js | 2 ++ 2 files changed, 15 insertions(+) diff --git a/app/javascript/mastodon/actions/compose.js b/app/javascript/mastodon/actions/compose.js index da3da6120e..aa23775085 100644 --- a/app/javascript/mastodon/actions/compose.js +++ b/app/javascript/mastodon/actions/compose.js @@ -242,9 +242,22 @@ export function submitCompose() { browserHistory.goBack(); } + + if ('scheduled_at' in response.data) { + dispatch(showAlert({ + message: messages.saved, + dismissAfter: 10000, + })); + dispatch(submitComposeSuccess({ ...response.data.params})); + return; + } + dispatch(insertIntoTagHistory(response.data.tags, status)); dispatch(submitComposeSuccess({ ...response.data })); + + + // To make the app more responsive, immediately push the status // into the columns const insertIfOnline = timelineId => { diff --git a/app/javascript/mastodon/reducers/compose.js b/app/javascript/mastodon/reducers/compose.js index f4b2640719..0218bc7f67 100644 --- a/app/javascript/mastodon/reducers/compose.js +++ b/app/javascript/mastodon/reducers/compose.js @@ -134,6 +134,8 @@ function clearAll(state) { map.update('media_attachments', list => list.clear()); map.set('poll', null); map.set('idempotencyKey', uuid()); + map.set('schedule_time', null); + map.set('is_scheduled', false); }); } From 64fca51f68b57564f81b924dd40dcdc5e5debeb8 Mon Sep 17 00:00:00 2001 From: dongzhimin Date: Sun, 20 Apr 2025 12:25:43 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E4=B8=8A=E6=AC=A1=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E7=9A=84BUG=E5=B7=B2=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/mastodon/reducers/compose.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/javascript/mastodon/reducers/compose.js b/app/javascript/mastodon/reducers/compose.js index 0218bc7f67..6b9a2c3ec4 100644 --- a/app/javascript/mastodon/reducers/compose.js +++ b/app/javascript/mastodon/reducers/compose.js @@ -136,6 +136,7 @@ function clearAll(state) { map.set('idempotencyKey', uuid()); map.set('schedule_time', null); map.set('is_scheduled', false); + map.set('scheduled_at', null); }); } @@ -578,7 +579,7 @@ export default function compose(state = initialState, action) { case COMPOSE_CHANGE_SCHEDULE_TIME: return state.withMutations(map => { map.set('schedule_time', action.value); - map.set('scheduled_at', state.get('schedule_time') + ':00.0' + state.get('schedule_timezone')); + map.set('scheduled_at', action.value + ':00.0' + state.get('schedule_timezone')); map.set('idempotencyKey', uuid()); }); default: From b0049e20b3b756588e32afcf1d4e880434ac6d39 Mon Sep 17 00:00:00 2001 From: dongzhimin Date: Sun, 20 Apr 2025 12:58:55 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E5=B7=B2=E6=B7=BB=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../features/compose/components/schedule_form.jsx | 7 +++++-- .../compose/containers/schedule_button_container.js | 11 +++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/javascript/mastodon/features/compose/components/schedule_form.jsx b/app/javascript/mastodon/features/compose/components/schedule_form.jsx index 35f818321f..435d9427d1 100644 --- a/app/javascript/mastodon/features/compose/components/schedule_form.jsx +++ b/app/javascript/mastodon/features/compose/components/schedule_form.jsx @@ -9,12 +9,15 @@ import { useDispatch, useSelector} from 'react-redux'; import { changeScheduleTime } from 'mastodon/actions/compose'; - +const messages = defineMessages({ + schedule_time: { id: 'compose_form.schedule_time', defaultMessage: '计划发文时间(北京时间)' }, +}); export const ScheduleForm = () => { const is_scheduled = useSelector(state => state.getIn(['compose', 'is_scheduled'])); const schedule_time = useSelector(state => state.getIn(['compose', 'schedule_time'])); const dispatch = useDispatch(); + const intl = useIntl(); const handleChange = useCallback(({ target: { value } }) => { dispatch(changeScheduleTime(value)); @@ -26,7 +29,7 @@ export const ScheduleForm = () => { return (
- + ({ +const mapStateToProps = (state, { intl }) => ({ iconComponent: ScheduleIcon, - title: 'schedule', + title: intl.formatMessage(state.getIn(['compose', 'is_scheduled']) ? messages.marked : messages.unmarked), active: state.getIn(['compose', 'is_scheduled']), - + ariaControls: 'schedule-publish', size: 18, inverted: true, }); From a479b2ac6b890bc9721d0ed5cfd1b040b463de48 Mon Sep 17 00:00:00 2001 From: dongzhimin Date: Fri, 2 May 2025 15:12:26 +0800 Subject: [PATCH 12/12] fixed i18n issue --- .../mastodon/features/compose/components/schedule_form.jsx | 2 +- .../features/compose/containers/schedule_button_container.js | 4 ++-- app/javascript/mastodon/locales/en.json | 3 +++ app/javascript/mastodon/locales/zh-CN.json | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/javascript/mastodon/features/compose/components/schedule_form.jsx b/app/javascript/mastodon/features/compose/components/schedule_form.jsx index 435d9427d1..64dc2b0020 100644 --- a/app/javascript/mastodon/features/compose/components/schedule_form.jsx +++ b/app/javascript/mastodon/features/compose/components/schedule_form.jsx @@ -10,7 +10,7 @@ import { useDispatch, useSelector} from 'react-redux'; import { changeScheduleTime } from 'mastodon/actions/compose'; const messages = defineMessages({ - schedule_time: { id: 'compose_form.schedule_time', defaultMessage: '计划发文时间(北京时间)' }, + schedule_time: { id: 'compose_form.schedule_time', defaultMessage: 'This post is scheduled to be published at (UTC+8)' }, }); export const ScheduleForm = () => { diff --git a/app/javascript/mastodon/features/compose/containers/schedule_button_container.js b/app/javascript/mastodon/features/compose/containers/schedule_button_container.js index 0ece8ffb82..5d92f95670 100644 --- a/app/javascript/mastodon/features/compose/containers/schedule_button_container.js +++ b/app/javascript/mastodon/features/compose/containers/schedule_button_container.js @@ -8,8 +8,8 @@ import { IconButton } from "@/mastodon/components/icon_button"; import { changeIsScheduled } from '../../../actions/compose'; const messages = defineMessages({ - marked: { id: 'compose_form.schedule.marked', defaultMessage: '本文将在以下时间发布'}, - unmarked: { id: 'compose_form.schedule.unmarked', defaultMessage: '文本将立即发布'}, + marked: { id: 'compose_form.schedule.marked', defaultMessage: 'This post will be published at the time chosen below'}, + unmarked: { id: 'compose_form.schedule.unmarked', defaultMessage: 'This post will be published at once'}, }) const mapStateToProps = (state, { intl }) => ({ diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json index ec3851be40..27ff191d1d 100644 --- a/app/javascript/mastodon/locales/en.json +++ b/app/javascript/mastodon/locales/en.json @@ -166,6 +166,9 @@ "compose_form.publish_form": "New post", "compose_form.reply": "Reply", "compose_form.save_changes": "Update", + "compose_form.schedule.marked": "This post will be published at the time chosen below", + "compose_form.schedule.unmarked": "This post will be published at once", + "compose_form.schedule_time": "This post is scheduled to be published at (UTC+8)", "compose_form.spoiler.marked": "Remove content warning", "compose_form.spoiler.unmarked": "Add content warning", "compose_form.spoiler_placeholder": "Content warning (optional)", diff --git a/app/javascript/mastodon/locales/zh-CN.json b/app/javascript/mastodon/locales/zh-CN.json index 914eb30e91..4a7e083c6e 100644 --- a/app/javascript/mastodon/locales/zh-CN.json +++ b/app/javascript/mastodon/locales/zh-CN.json @@ -166,6 +166,9 @@ "compose_form.publish_form": "发嘟", "compose_form.reply": "回复", "compose_form.save_changes": "更改", + "compose_form.schedule.marked": "本文将在以下时间发布", + "compose_form.schedule.unmarked": "本文将立即发布", + "compose_form.schedule_time": "计划发文时间(北京时间)", "compose_form.spoiler.marked": "移除内容警告", "compose_form.spoiler.unmarked": "添加内容警告", "compose_form.spoiler_placeholder": "内容警告 (可选)",