mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-01 01:35:11 +00:00
fix publishForm flow errors
This commit is contained in:
parent
b49df1fc0a
commit
334f582a4d
1 changed files with 11 additions and 6 deletions
|
@ -37,9 +37,9 @@ const MODES = Object.values(PUBLISH_MODES);
|
||||||
type Props = {
|
type Props = {
|
||||||
disabled: boolean,
|
disabled: boolean,
|
||||||
tags: Array<Tag>,
|
tags: Array<Tag>,
|
||||||
publish: (?string) => void,
|
publish: (source?: string | File) => void,
|
||||||
filePath: ?string,
|
filePath: string | File,
|
||||||
fileText: ?string,
|
fileText: string,
|
||||||
bid: ?number,
|
bid: ?number,
|
||||||
bidError: ?string,
|
bidError: ?string,
|
||||||
editingURI: ?string,
|
editingURI: ?string,
|
||||||
|
@ -217,7 +217,9 @@ function PublishForm(props: Props) {
|
||||||
function createWebFile() {
|
function createWebFile() {
|
||||||
if (fileText) {
|
if (fileText) {
|
||||||
const fileName = name || title;
|
const fileName = name || title;
|
||||||
return new File([fileText], `${fileName}.md`, { type: 'text/markdown' });
|
if (fileName) {
|
||||||
|
return new File([fileText], `${fileName}.md`, { type: 'text/markdown' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// @endif
|
// @endif
|
||||||
|
@ -225,13 +227,16 @@ function PublishForm(props: Props) {
|
||||||
// @if TARGET='app'
|
// @if TARGET='app'
|
||||||
// Save file changes locally ( desktop )
|
// Save file changes locally ( desktop )
|
||||||
function saveFileChanges() {
|
function saveFileChanges() {
|
||||||
let output = filePath;
|
let output;
|
||||||
if (!output || output === '') {
|
if (!output || output === '') {
|
||||||
// Generate a temporary file:
|
// Generate a temporary file:
|
||||||
output = tempy.file({ name: 'post.md' });
|
output = tempy.file({ name: 'post.md' });
|
||||||
|
} else if (typeof filePath === 'string') {
|
||||||
|
// Use current file
|
||||||
|
output = filePath;
|
||||||
}
|
}
|
||||||
// Create a temporary file and save file changes
|
// Create a temporary file and save file changes
|
||||||
if (typeof output === 'string') {
|
if (output && output !== '') {
|
||||||
// Save file changes
|
// Save file changes
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
fs.writeFile(output, fileText, (error, data) => {
|
fs.writeFile(output, fileText, (error, data) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue