Update publish form when editing livestream + update to radios for liveststream release time

This commit is contained in:
Dan Peterson 2021-12-22 15:45:47 -06:00 committed by Thomas Zarebczan
parent d4866b09bb
commit 7671d12e42
3 changed files with 12 additions and 16 deletions

View file

@ -114,7 +114,7 @@ function PublishFile(props: Props) {
const fileSelectorModes = [ const fileSelectorModes = [
{ label: __('Upload'), actionName: SOURCE_UPLOAD, icon: ICONS.PUBLISH }, { label: __('Upload'), actionName: SOURCE_UPLOAD, icon: ICONS.PUBLISH },
{ label: __('Choose Replay'), actionName: SOURCE_SELECT, icon: ICONS.MENU }, { label: __('Choose Replay'), actionName: SOURCE_SELECT, icon: ICONS.MENU },
{ label: __('None'), actionName: SOURCE_NONE }, { label: isLivestreamClaim ? __('Edit / Update') : __('None'), actionName: SOURCE_NONE },
]; ];
const livestreamDataStr = JSON.stringify(livestreamData); const livestreamDataStr = JSON.stringify(livestreamData);
@ -144,10 +144,7 @@ function PublishFile(props: Props) {
// set default file source to select if necessary // set default file source to select if necessary
useEffect(() => { useEffect(() => {
if (hasLivestreamData && isLivestreamClaim) { if (isLivestreamClaim) {
setWaitForFile(true);
setFileSelectSource(SOURCE_SELECT);
} else if (isLivestreamClaim) {
setFileSelectSource(SOURCE_NONE); setFileSelectSource(SOURCE_NONE);
} }
}, [hasLivestreamData, isLivestreamClaim, setFileSelectSource]); }, [hasLivestreamData, isLivestreamClaim, setFileSelectSource]);
@ -437,7 +434,7 @@ function PublishFile(props: Props) {
updatePublishForm(publishFormParams); updatePublishForm(publishFormParams);
} }
const showFileUpload = mode === PUBLISH_MODES.FILE; const showFileUpload = mode === PUBLISH_MODES.FILE || PUBLISH_MODES.LIVESTREAM;
const isPublishPost = mode === PUBLISH_MODES.POST; const isPublishPost = mode === PUBLISH_MODES.POST;
return ( return (

View file

@ -173,7 +173,8 @@ function PublishForm(props: Props) {
[PUBLISH_MODES.LIVESTREAM]: 'Livestream --[noun, livestream tab button]--', [PUBLISH_MODES.LIVESTREAM]: 'Livestream --[noun, livestream tab button]--',
}; };
const [mode, setMode] = React.useState(_uploadType || PUBLISH_MODES.FILE); const defaultPublishMode = isLivestreamClaim ? PUBLISH_MODES.LIVESTREAM : PUBLISH_MODES.FILE;
const [mode, setMode] = React.useState(_uploadType || defaultPublishMode);
const [isCheckingLivestreams, setCheckingLivestreams] = React.useState(false); const [isCheckingLivestreams, setCheckingLivestreams] = React.useState(false);
let customSubtitle; let customSubtitle;
@ -422,9 +423,8 @@ function PublishForm(props: Props) {
// set mode based on urlParams 'type' // set mode based on urlParams 'type'
useEffect(() => { useEffect(() => {
// Default to standard file publish if none specified
if (!_uploadType) { if (!_uploadType) {
setMode(PUBLISH_MODES.FILE); setMode(defaultPublishMode);
return; return;
} }
@ -448,9 +448,8 @@ function PublishForm(props: Props) {
return; return;
} }
// Default to standard file publish setMode(defaultPublishMode);
setMode(PUBLISH_MODES.FILE); }, [_uploadType, enableLivestream, defaultPublishMode]);
}, [_uploadType, enableLivestream]);
// if we have a type urlparam, update it? necessary? // if we have a type urlparam, update it? necessary?
useEffect(() => { useEffect(() => {

View file

@ -59,8 +59,8 @@ const PublishStreamReleaseDate = (props: Props) => {
<div className={'w-full flex flex-col mt-s md:mt-0 md:h-12 md:items-center md:flex-row'}> <div className={'w-full flex flex-col mt-s md:mt-0 md:h-12 md:items-center md:flex-row'}>
<FormField <FormField
type="checkbox" type="radio"
name="rightNow" name="anytime"
disabled={false} disabled={false}
onChange={handleToggle} onChange={handleToggle}
checked={!publishLater} checked={!publishLater}
@ -69,8 +69,8 @@ const PublishStreamReleaseDate = (props: Props) => {
<div className={'md:ml-m mt-s md:mt-0'}> <div className={'md:ml-m mt-s md:mt-0'}>
<FormField <FormField
type="checkbox" type="radio"
name="rightNow" name="scheduled_time"
disabled={false} disabled={false}
onChange={handleToggle} onChange={handleToggle}
checked={publishLater} checked={publishLater}