Flush Fix

This commit is contained in:
srgooglo 2020-03-08 03:26:27 +01:00
parent b77941ed30
commit d7abb0c4a9

View File

@ -91,12 +91,10 @@ class PostCreator extends React.PureComponent{
const filter = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'video/mp4'; const filter = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'video/mp4';
if (!filter) { if (!filter) {
antd.message.error('Invalid File!'); antd.message.error('Invalid File!');
this.FlushPostState('error')
} }
const maxsize = file.size / 1024 / 1024 < ycore.DevOptions.MaximunAPIPayload; const maxsize = file.size / 1024 / 1024 < ycore.DevOptions.MaximunAPIPayload;
if (!maxsize) { if (!maxsize) {
antd.message.error('Image must smaller than 99MB!'); antd.message.error('Image must smaller than 99MB!');
this.FlushPostState('error')
} }
return filter && maxsize; return filter && maxsize;
} }
@ -116,31 +114,17 @@ class PostCreator extends React.PureComponent{
this.setState({ toolbox_open: !this.state.toolbox_open }) this.setState({ toolbox_open: !this.state.toolbox_open })
} }
FlushPostState = (type) =>{ FlushPostState(){
switch (type) { this.setState({
case 'error': posting_ok: true,
this.setState({ posting: false,
posting_ok: false, rawtext: '',
posting: false, fileURL: '',
rawtext: '', file: ''
fileURL: '', })
file: '' setTimeout( () => {this.setState({ posting_ok: false }) }, 1000)
}) RefreshFeed()
setTimeout( () => {this.setState({ posting_ok: false }) }, 1000) return true
break;
default:
this.setState({
posting_ok: true,
posting: false,
rawtext: '',
fileURL: '',
file: ''
})
setTimeout( () => {this.setState({ posting_ok: false }) }, 1000)
RefreshFeed()
return
}
} }
handlePublishPost = (e) => { handlePublishPost = (e) => {