minor cleanup and tested with actual livestream
This commit is contained in:
@@ -16,7 +16,9 @@ interface EditBioFormProps {
|
|||||||
|
|
||||||
function EditBioForm(props: EditBioFormProps) {
|
function EditBioForm(props: EditBioFormProps) {
|
||||||
const [formBio, setFormBio] = useState<string>(props.entity.bio);
|
const [formBio, setFormBio] = useState<string>(props.entity.bio);
|
||||||
const [formLivestreamId, setFormLivestreamId] = useState<string | undefined>(props.livestream_id)
|
const [formLivestreamId, setFormLivestreamId] = useState<string | undefined>(
|
||||||
|
props.livestream_id,
|
||||||
|
);
|
||||||
const [canSubmit, setCanSubmit] = useState<boolean>(false);
|
const [canSubmit, setCanSubmit] = useState<boolean>(false);
|
||||||
const [error, setError] = useState<string>("");
|
const [error, setError] = useState<string>("");
|
||||||
|
|
||||||
@@ -25,10 +27,12 @@ function EditBioForm(props: EditBioFormProps) {
|
|||||||
setCanSubmit(true);
|
setCanSubmit(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleLivestreamChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
const handleLivestreamChange = (
|
||||||
|
event: React.ChangeEvent<HTMLTextAreaElement>,
|
||||||
|
) => {
|
||||||
setFormLivestreamId(event.target.value);
|
setFormLivestreamId(event.target.value);
|
||||||
setCanSubmit(true);
|
setCanSubmit(true);
|
||||||
}
|
};
|
||||||
|
|
||||||
const handleSubmit = async (event: React.FormEvent) => {
|
const handleSubmit = async (event: React.FormEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -97,10 +101,12 @@ function EditBioForm(props: EditBioFormProps) {
|
|||||||
{props.livestream_id != undefined && (
|
{props.livestream_id != undefined && (
|
||||||
<Form.Group controlId="formLivestreamId">
|
<Form.Group controlId="formLivestreamId">
|
||||||
<p className="text-muted">
|
<p className="text-muted">
|
||||||
A livestream id is the part of a youtube url following "v=".
|
A livestream id is part of a youtube url. Either
|
||||||
For example, "ncyl7cTU9k8" but without the quotations.
|
".../v=[livestream_id]" or ".../live/[livestream_id]". For example,
|
||||||
Don't mess it up. <br></br>
|
"ncyl7cTU9k8" but without the quotations. Don't mess it up.{" "}
|
||||||
To remove an embedded livestream, just clear this field and submit the form.
|
<br></br>
|
||||||
|
To remove an embedded livestream, just clear this field and submit
|
||||||
|
the form.
|
||||||
</p>
|
</p>
|
||||||
<Form.Label>Livestream ID:</Form.Label>
|
<Form.Label>Livestream ID:</Form.Label>
|
||||||
<Form.Control
|
<Form.Control
|
||||||
@@ -108,9 +114,8 @@ function EditBioForm(props: EditBioFormProps) {
|
|||||||
value={formLivestreamId}
|
value={formLivestreamId}
|
||||||
rows={1}
|
rows={1}
|
||||||
onChange={handleLivestreamChange}
|
onChange={handleLivestreamChange}
|
||||||
placeholder="ncyl7cTU9k8"
|
placeholder=""
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
)}
|
)}
|
||||||
<Form.Group controlId="formBio">
|
<Form.Group controlId="formBio">
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ interface LivestreamPlayerProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const LivestreamPlayer = (props: LivestreamPlayerProps) => {
|
const LivestreamPlayer = (props: LivestreamPlayerProps) => {
|
||||||
const iframeSrc = `https://www.youtube.com/embed/${props.livestreamId}`;
|
const iframeSrc = `https://www.youtube.com/embed/${props.livestreamId}?autoplay=1`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className="d-flex justify-content-center my-3">
|
<Container className="d-flex justify-content-center my-3">
|
||||||
|
|||||||
Reference in New Issue
Block a user