Fix inline image attachment support

This commit is contained in:
Ben Gotow 2017-11-12 19:37:48 +01:00
parent 3cdc3c27c6
commit 69c7a7aea7
6 changed files with 11 additions and 6 deletions

View file

@ -533,7 +533,7 @@ export default class ComposerView extends React.Component {
return;
}
match.contentId = Utils.generateTempId();
match.contentId = Utils.generateContentId();
session.changes.add({
files: [].concat(draft.files),
});

View file

@ -147,12 +147,12 @@ export default class InlineImageUploadContainer extends Component {
return <span />;
}
if (isPreview) {
return <img src={`cid:${file.id}`} alt={file.name} />;
return <img src={`cid:${file.contentId}`} alt={file.name} />;
}
return (
<div
data-src={`cid:${file.id}`}
data-src={`cid:${file.contentId}`}
className="inline-image-upload-container"
onDoubleClick={this._onGoEdit}
>

View file

@ -155,6 +155,11 @@ Utils =
Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1)
'local-' + s4() + s4() + '-' + s4()
generateContentId: ->
s4 = ->
Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1)
'mcid-' + s4() + s4() + '-' + s4()
isTempId: (id) ->
return false unless id and _.isString(id)
id[0..5] is 'local-'

View file

@ -436,7 +436,7 @@ class AttachmentStore extends MailspringStore {
size: stats.size,
contentType: null,
messageId: null,
contentId: inline ? Utils.generateTempId() : null,
contentId: inline ? Utils.generateContentId() : null,
});
await mkdirpAsync(path.dirname(this.pathForFile(file)));

View file

@ -59,7 +59,7 @@ class DraftHelpers {
async pruneRemovedInlineFiles(draft) {
draft.files = draft.files.filter(f => {
return !(f.contentId && !draft.body.includes(`cid:${f.id}`));
return !(f.contentId && !draft.body.includes(`cid:${f.contentId}`));
});
return draft;

@ -1 +1 @@
Subproject commit f5625c3c8d102856a2c4b838e9d40f751b1df216
Subproject commit d4b6bdc8b9ef6fec0023d59c94e9f71de72f99ef