mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-14 17:41:33 +03:00
Merge pull request #3607 from tylershuster/firefox-image-paste
landscape: delay uploading briefly to account for browser inconsistencies
This commit is contained in:
commit
68047b073c
@ -162,12 +162,9 @@ export default class ChatInput extends Component<ChatInputProps, ChatInputState>
|
|||||||
}
|
}
|
||||||
if (!this.s3Uploader.current || !this.s3Uploader.current.inputRef.current) return;
|
if (!this.s3Uploader.current || !this.s3Uploader.current.inputRef.current) return;
|
||||||
this.s3Uploader.current.inputRef.current.files = files;
|
this.s3Uploader.current.inputRef.current.files = files;
|
||||||
setTimeout(() => {
|
const fire = document.createEvent("HTMLEvents");
|
||||||
if (this.s3Uploader.current.state.isUploading) return;
|
fire.initEvent("change", true, true);
|
||||||
const fire = document.createEvent("HTMLEvents");
|
this.s3Uploader.current?.inputRef.current?.dispatchEvent(fire);
|
||||||
fire.initEvent("change", true, true);
|
|
||||||
this.s3Uploader.current?.inputRef.current?.dispatchEvent(fire);
|
|
||||||
}, 200);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -99,22 +99,25 @@ export class S3Upload extends Component<S3UploadProps, S3UploadState> {
|
|||||||
const timestamp = deSig(dateToDa(new Date()));
|
const timestamp = deSig(dateToDa(new Date()));
|
||||||
let bucket = props.configuration.currentBucket;
|
let bucket = props.configuration.currentBucket;
|
||||||
|
|
||||||
this.setState({ isUploading: true });
|
setTimeout(() => {
|
||||||
|
if (this.state.isUploading) return;
|
||||||
|
this.setState({ isUploading: true });
|
||||||
|
this.s3.upload(bucket, `${window.ship}/${timestamp}-${fileName}.${fileExtension}`, file)
|
||||||
|
.then((data) => {
|
||||||
|
if (!data || !('Location' in data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.props.uploadSuccess(data.Location);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
this.props.uploadError(err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.setState({ isUploading: false });
|
||||||
|
});
|
||||||
|
}, 200);
|
||||||
|
|
||||||
this.s3.upload(bucket, `${window.ship}/${timestamp}-${fileName}.${fileExtension}`, file)
|
|
||||||
.then((data) => {
|
|
||||||
if (!data || !('Location' in data)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.props.uploadSuccess(data.Location);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.error(err);
|
|
||||||
this.props.uploadError(err);
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
this.setState({ isUploading: false });
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onClick() {
|
onClick() {
|
||||||
|
Loading…
Reference in New Issue
Block a user