-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add timeline on mobile post (#1863)
* fix: add selected timeline id on import post, remove view details timeline on post * fix: add video upload on mobile * fix: add timeline id on mobile
- Loading branch information
Showing
6 changed files
with
147 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import { Upload } from 'components/Upload'; | ||
import { Modal } from 'components/atoms/Modal'; | ||
import * as UploadAPI from 'src/lib/api/upload'; | ||
import i18n from 'src/locale'; | ||
|
||
export const MediaEmbedToolbarButton = ({ | ||
userId, | ||
onFileSelected, | ||
modalOpen, | ||
...props | ||
}) => { | ||
const [progress, setProgress] = useState(0); | ||
const [open, setOpen] = useState(modalOpen ?? false); | ||
|
||
const handleFileSelected = async (files: File[]) => { | ||
if (files.length === 0) return; | ||
|
||
try { | ||
const { files: uploadedFiles } = await UploadAPI.videoMobile(files[0], { | ||
onUploadProgress: (event: ProgressEvent) => { | ||
const total = Math.round((100 * event.loaded) / event.total); | ||
|
||
setProgress(total); | ||
}, | ||
}); | ||
|
||
onFileSelected(uploadedFiles); | ||
|
||
setProgress(0); | ||
setOpen(false); | ||
} catch (error) { | ||
console.error('ERROR', error); | ||
} | ||
}; | ||
|
||
return ( | ||
<Modal | ||
title={i18n.t('Post_Create.Upload.Video.Title')} | ||
align="left" | ||
titleSize="small" | ||
maxWidth="xl" | ||
open={open} | ||
onClose={() => setOpen(false)}> | ||
<Upload | ||
type="video" | ||
progress={progress} | ||
loading={progress > 0} | ||
onFileSelected={handleFileSelected} | ||
accept={['video/mp4', 'video/x-m4v', 'video/*']} | ||
maxSize={100} | ||
placeholder={i18n.t('Post_Create.Upload.Video.Placeholder')} | ||
usage="post" | ||
/> | ||
</Modal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters