mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-02 18:25:12 +00:00
fix fileReader flow errors
This commit is contained in:
parent
334f582a4d
commit
2d47dd1780
2 changed files with 11 additions and 5 deletions
|
@ -47,6 +47,7 @@ function PostEditor(props: Props) {
|
||||||
|
|
||||||
// Ready to edit content
|
// Ready to edit content
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// flow error
|
||||||
if (!ready && !loading && fileText && streamingUrl) {
|
if (!ready && !loading && fileText && streamingUrl) {
|
||||||
setReady(true);
|
setReady(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,6 +232,15 @@ function PublishFile(props: Props) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleFileReaderLoaded(event: ProgressEvent) {
|
||||||
|
// See: https://github.com/facebook/flow/issues/3470
|
||||||
|
if (event.target instanceof FileReader) {
|
||||||
|
const text = event.target.result;
|
||||||
|
updatePublishForm({ fileText: text });
|
||||||
|
setPublishMode(PUBLISH_MODES.POST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handleFileChange(file: WebFile) {
|
function handleFileChange(file: WebFile) {
|
||||||
const { showToast } = props;
|
const { showToast } = props;
|
||||||
window.URL = window.URL || window.webkitURL;
|
window.URL = window.URL || window.webkitURL;
|
||||||
|
@ -283,11 +292,7 @@ function PublishFile(props: Props) {
|
||||||
// Create reader
|
// Create reader
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
// Handler for file reader
|
// Handler for file reader
|
||||||
reader.addEventListener('load', event => {
|
reader.addEventListener('load', handleFileReaderLoaded);
|
||||||
const text = event.target.result;
|
|
||||||
updatePublishForm({ fileText: text });
|
|
||||||
setPublishMode(PUBLISH_MODES.POST);
|
|
||||||
});
|
|
||||||
// Read file contents
|
// Read file contents
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
setCurrentFileType('text/markdown');
|
setCurrentFileType('text/markdown');
|
||||||
|
|
Loading…
Add table
Reference in a new issue