mirror of
https://github.com/hyperspacedev/hyperspace
synced 2025-02-04 03:08:10 +01:00
Merge pull request #33 from hyperspacedev/media-uploads
Fix persistent media upload snackbar
This commit is contained in:
commit
bd9e096bd8
@ -140,7 +140,7 @@ class Composer extends Component<any, IComposerState> {
|
|||||||
}).then((media: FileList) => {
|
}).then((media: FileList) => {
|
||||||
let mediaForm = new FormData();
|
let mediaForm = new FormData();
|
||||||
mediaForm.append('file', media[0]);
|
mediaForm.append('file', media[0]);
|
||||||
const uploading = this.props.enqueueSnackbar("Uploading media...", { persist: true })
|
this.props.enqueueSnackbar("Uploading media...", { persist: true, key: "media-upload" })
|
||||||
this.client.post('/media', mediaForm).then((resp: any) => {
|
this.client.post('/media', mediaForm).then((resp: any) => {
|
||||||
let attachment: Attachment = resp.data;
|
let attachment: Attachment = resp.data;
|
||||||
let attachments = this.state.attachments;
|
let attachments = this.state.attachments;
|
||||||
@ -150,13 +150,14 @@ class Composer extends Component<any, IComposerState> {
|
|||||||
attachments = [attachment];
|
attachments = [attachment];
|
||||||
}
|
}
|
||||||
this.setState({ attachments });
|
this.setState({ attachments });
|
||||||
this.props.closeSnackbar(uploading);
|
this.props.closeSnackbar("media-upload");
|
||||||
this.props.enqueueSnackbar('Media uploaded.');
|
this.props.enqueueSnackbar('Media uploaded.');
|
||||||
}).catch((err: Error) => {
|
}).catch((err: Error) => {
|
||||||
this.props.enqueueSnackbar("Couldn't upload media: " + err.name);
|
this.props.closeSnackbar("media-upload");
|
||||||
|
this.props.enqueueSnackbar("Couldn't upload media: " + err.name, { variant: "error" });
|
||||||
})
|
})
|
||||||
}).catch((err: Error) => {
|
}).catch((err: Error) => {
|
||||||
this.props.enqueueSnackbar("Couldn't get media: " + err.name);
|
this.props.enqueueSnackbar("Couldn't get media: " + err.name, { variant: "error" });
|
||||||
console.error(err.message);
|
console.error(err.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user