mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-24 13:53:23 +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]);
|
}, [isLoading]);
|
||||||
|
|
||||||
// useEffect(() => {
|
useEffect(() => {
|
||||||
// if (uploadedImage && uploadedImage.url) {
|
if (uploadedImage && uploadedImage.url && uploadedImage.shouldInsert) {
|
||||||
// applyImageLink({
|
applyImageLink({
|
||||||
// text,
|
text,
|
||||||
// selection,
|
selection,
|
||||||
// setTextAndSelection: _setTextAndSelection,
|
setTextAndSelection: _setTextAndSelection,
|
||||||
// item: { url: uploadedImage.url, text: uploadedImage.hash },
|
item: { url: uploadedImage.url, text: uploadedImage.hash },
|
||||||
// isImage: !!uploadedImage,
|
isImage: !!uploadedImage,
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
// }, [uploadedImage]);
|
}, [uploadedImage]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setText(draftBody);
|
setText(draftBody);
|
||||||
|
@ -103,14 +103,14 @@ class EditorContainer extends Component {
|
|||||||
|
|
||||||
upload.forEach((el) => {
|
upload.forEach((el) => {
|
||||||
if (el.filePath && el.fileName) {
|
if (el.filePath && el.fileName) {
|
||||||
this.setState({ isUploading: true });
|
// this.setState({ isUploading: true });
|
||||||
const _media = {
|
const _media = {
|
||||||
path: el.filePath,
|
path: el.filePath,
|
||||||
mime: el.mimeType,
|
mime: el.mimeType,
|
||||||
filename: el.fileName || `img_${Math.random()}.jpg`,
|
filename: el.fileName || `img_${Math.random()}.jpg`,
|
||||||
};
|
};
|
||||||
|
|
||||||
this._uploadImage(_media);
|
this._uploadImage(_media, { shouldInsert: true });
|
||||||
} else if (el.text) {
|
} else if (el.text) {
|
||||||
this.setState({
|
this.setState({
|
||||||
draftPost: {
|
draftPost: {
|
||||||
@ -370,7 +370,7 @@ class EditorContainer extends Component {
|
|||||||
// const data = new Buffer(media.data, 'base64');
|
// const data = new Buffer(media.data, 'base64');
|
||||||
};
|
};
|
||||||
|
|
||||||
_uploadImage = async (media) => {
|
_uploadImage = async (media, { shouldInsert } = { shouldInsert: false }) => {
|
||||||
const { intl, currentAccount, pinCode, isLoggedIn } = this.props;
|
const { intl, currentAccount, pinCode, isLoggedIn } = this.props;
|
||||||
|
|
||||||
if (!isLoggedIn) return;
|
if (!isLoggedIn) return;
|
||||||
@ -385,9 +385,11 @@ class EditorContainer extends Component {
|
|||||||
const res = await uploadImage(media, currentAccount.name, sign);
|
const res = await uploadImage(media, currentAccount.name, sign);
|
||||||
if (res.data && res.data.url) {
|
if (res.data && res.data.url) {
|
||||||
res.data.hash = res.data.url.split('/').pop();
|
res.data.hash = res.data.url.split('/').pop();
|
||||||
|
res.data.shouldInsert = shouldInsert;
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
uploadedImage: res.data,
|
|
||||||
isUploading: false,
|
isUploading: false,
|
||||||
|
uploadedImage: res.data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user