mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-24 05:42:33 +03:00
added special insert flag with image uploads for handling shared image uploads
This commit is contained in:
parent
fec5119e28
commit
a15602b2dc
@ -109,17 +109,17 @@ const MarkdownEditorView = ({
|
||||
}
|
||||
}, [isLoading]);
|
||||
|
||||
// useEffect(() => {
|
||||
// if (uploadedImage && uploadedImage.url) {
|
||||
// applyImageLink({
|
||||
// text,
|
||||
// selection,
|
||||
// setTextAndSelection: _setTextAndSelection,
|
||||
// item: { url: uploadedImage.url, text: uploadedImage.hash },
|
||||
// isImage: !!uploadedImage,
|
||||
// });
|
||||
// }
|
||||
// }, [uploadedImage]);
|
||||
useEffect(() => {
|
||||
if (uploadedImage && uploadedImage.url && uploadedImage.shouldInsert) {
|
||||
applyImageLink({
|
||||
text,
|
||||
selection,
|
||||
setTextAndSelection: _setTextAndSelection,
|
||||
item: { url: uploadedImage.url, text: uploadedImage.hash },
|
||||
isImage: !!uploadedImage,
|
||||
});
|
||||
}
|
||||
}, [uploadedImage]);
|
||||
|
||||
useEffect(() => {
|
||||
setText(draftBody);
|
||||
|
@ -103,14 +103,14 @@ class EditorContainer extends Component {
|
||||
|
||||
upload.forEach((el) => {
|
||||
if (el.filePath && el.fileName) {
|
||||
this.setState({ isUploading: true });
|
||||
// this.setState({ isUploading: true });
|
||||
const _media = {
|
||||
path: el.filePath,
|
||||
mime: el.mimeType,
|
||||
filename: el.fileName || `img_${Math.random()}.jpg`,
|
||||
};
|
||||
|
||||
this._uploadImage(_media);
|
||||
this._uploadImage(_media, { shouldInsert: true });
|
||||
} else if (el.text) {
|
||||
this.setState({
|
||||
draftPost: {
|
||||
@ -370,7 +370,7 @@ class EditorContainer extends Component {
|
||||
// const data = new Buffer(media.data, 'base64');
|
||||
};
|
||||
|
||||
_uploadImage = async (media) => {
|
||||
_uploadImage = async (media, { shouldInsert } = { shouldInsert: false }) => {
|
||||
const { intl, currentAccount, pinCode, isLoggedIn } = this.props;
|
||||
|
||||
if (!isLoggedIn) return;
|
||||
@ -385,9 +385,11 @@ class EditorContainer extends Component {
|
||||
const res = await uploadImage(media, currentAccount.name, sign);
|
||||
if (res.data && res.data.url) {
|
||||
res.data.hash = res.data.url.split('/').pop();
|
||||
res.data.shouldInsert = shouldInsert;
|
||||
|
||||
this.setState({
|
||||
uploadedImage: res.data,
|
||||
isUploading: false,
|
||||
uploadedImage: res.data,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
|
Loading…
Reference in New Issue
Block a user