Skip to content

Commit

Permalink
Remember scheduled time in the edit-form time picker
Browse files Browse the repository at this point in the history
  • Loading branch information
miko committed Nov 7, 2023
1 parent e632171 commit 7f7cda2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
11 changes: 2 additions & 9 deletions ui/component/publish/shared/publishStreamReleaseDate/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ type Props = {
const PublishStreamReleaseDate = (props: Props) => {
const { isScheduled, releaseTime, clock24h, appLanguage, updatePublishForm } = props;

const [publishLater, setPublishLater] = React.useState(isScheduled);
const minScheduledTimePassed = releaseTime ? releaseTime < dateToLinuxTimestamp(moment().toDate()) : undefined;
const [publishLater, setPublishLater] = React.useState(isScheduled && !minScheduledTimePassed);

const getPlus30MinutesDate = () => {
return moment().add('1', 'hour').add('30', 'minutes').startOf('hour').toDate();
Expand Down Expand Up @@ -50,14 +51,6 @@ const PublishStreamReleaseDate = (props: Props) => {
'Your scheduled streams will appear on your channel page and for your followers. Chat will not be active until 5 minutes before the start time.'
);

React.useEffect(() => {
if (isScheduled) {
// TODO: this is doPrepareEdit's responsibility, not the component's.
updatePublishForm({ releaseTime: dateToLinuxTimestamp(getPlus30MinutesDate()) });
}
// eslint-disable-next-line react-hooks/exhaustive-deps -- on mount only
}, []);

return (
<>
<div className="publish-row">
Expand Down
3 changes: 3 additions & 0 deletions ui/redux/actions/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ export const doPrepareEdit = (claim: StreamClaim, uri: string, claimType: string
title,
tags,
stream_type,
release_time,
} = value;

let state = getState();
Expand Down Expand Up @@ -749,6 +750,8 @@ export const doPrepareEdit = (claim: StreamClaim, uri: string, claimType: string
dispatch(doSetIncognito(true));
}

publishData.releaseTime = Number(release_time);

dispatch({ type: ACTIONS.DO_PREPARE_EDIT, data: publishData });
dispatch(push(`/$/${PUBLISH_PATH_MAP[type]}`));
};
Expand Down

0 comments on commit 7f7cda2

Please sign in to comment.